Skip to content

Commit 5b8cf1f

Browse files
authored
Release/1.5.5 (#13)
* CONTMS-128 Work with Intento glossaries in the memoQ (Trados) plugin
1 parent 84298bb commit 5b8cf1f

3 files changed

Lines changed: 64 additions & 6 deletions

File tree

IntentoSDK/IntentoAiTextTranslate.cs

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
5+
using System.Reflection;
46
using System.Threading.Tasks;
57
using System.Web;
68
using Newtonsoft.Json;
@@ -27,14 +29,14 @@ public IntentoAiText Parent
2729

2830
public dynamic Fulfill(object text, string to, string from = null, string provider = null,
2931
bool async = false, bool wait_async = false, string format = null, object auth = null,
30-
string custom_model = null, string glossary = null,
32+
string custom_model = null, string glossary = null, int[] intentoGlossary = null,
3133
object pre_processing = null, object post_processing = null,
3234
bool failover = false, object failover_list = null, string routing = null, bool trace = false,
3335
Dictionary<string, string> special_headers = null, bool useSyncwrapper = false)
3436
{
3537
Task<dynamic> taskReadResult = Task.Run<dynamic>(async () => await this.FulfillAsync(text, to, from: from, provider: provider,
3638
async: async, wait_async: wait_async, format: format, auth: auth,
37-
custom_model: custom_model, glossary: glossary,
39+
custom_model: custom_model, glossary: glossary, intentoGlossary: intentoGlossary,
3840
pre_processing: pre_processing, post_processing: post_processing,
3941
failover: failover, failover_list: failover_list, routing: routing, trace: trace,
4042
special_headers: special_headers, useSyncwrapper: useSyncwrapper));
@@ -43,7 +45,7 @@ public dynamic Fulfill(object text, string to, string from = null, string provid
4345

4446
async public Task<dynamic> FulfillAsync(object text, string to, string from = null, string provider = null,
4547
bool async = false, bool wait_async = false, string format = null, object auth = null,
46-
string custom_model = null, string glossary = null,
48+
string custom_model = null, string glossary = null, int[] intentoGlossary = null,
4749
object pre_processing = null, object post_processing = null,
4850
bool failover = false, object failover_list = null, string routing = null, bool trace = false,
4951
Dictionary<string, string> special_headers = null, bool useSyncwrapper = false)
@@ -100,6 +102,13 @@ async public Task<dynamic> FulfillAsync(object text, string to, string from = nu
100102
if (!string.IsNullOrWhiteSpace(glossary))
101103
context.glossary = glossary;
102104

105+
// intento glossary
106+
if (intentoGlossary != null && intentoGlossary.Length > 0)
107+
{
108+
dynamic intentoG = JArray.FromObject(intentoGlossary.Select(g => JObject.FromObject(new { id = g })));
109+
context.glossary = intentoG;
110+
}
111+
103112
json.context = context;
104113

105114
// ----- service section
@@ -403,6 +412,54 @@ async public Task<IList<dynamic>> GlossariesAsync(string providerId, Dictionary<
403412
return glossaries;
404413
}
405414

415+
public IList<dynamic> AgnosticGlossaries()
416+
{
417+
Task<dynamic> taskReadResult = Task.Run<dynamic>(async () =>
418+
await AgnosticGlossariesAsync());
419+
return taskReadResult.Result;
420+
}
421+
422+
public async Task<IList<dynamic>> AgnosticGlossariesAsync()
423+
{
424+
var path = $"ai/text/glossaries/v2/typed";
425+
dynamic jsonResult;
426+
// Call to Intento API and get json result
427+
using (HttpConnector conn = new HttpConnector(Intento))
428+
{
429+
jsonResult = await conn.GetAsync(path);
430+
}
431+
var glossaries = new List<dynamic>();
432+
foreach (dynamic glossary in jsonResult.glossaries)
433+
{
434+
glossaries.Add(glossary);
435+
}
436+
return glossaries;
437+
}
438+
439+
public IList<dynamic> AgnosticGlossariesTypes()
440+
{
441+
Task<dynamic> taskReadResult = Task.Run<dynamic>(async () =>
442+
await AgnosticGlossariesTypesAsync());
443+
return taskReadResult.Result;
444+
}
445+
446+
public async Task<IList<dynamic>> AgnosticGlossariesTypesAsync()
447+
{
448+
var path = $"ai/text/glossaries/v2/cs_types";
449+
dynamic jsonResult;
450+
// Call to Intento API and get json result
451+
using (HttpConnector conn = new HttpConnector(Intento))
452+
{
453+
jsonResult = await conn.GetAsync(path);
454+
}
455+
var types = new List<dynamic>();
456+
foreach (dynamic type in jsonResult.types)
457+
{
458+
types.Add(type);
459+
}
460+
return types;
461+
}
462+
406463
/// <summary>
407464
/// Get a list of available delegated credentials
408465
/// </summary>

IntentoSDK/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("1.5.4.0")]
37-
[assembly: AssemblyFileVersion("1.5.4.0")]
36+
[assembly: AssemblyVersion("1.5.5.0")]
37+
[assembly: AssemblyFileVersion("1.5.5.0")]
3838
[assembly: AssemblyInformationalVersion(GitHash.hash)]
3939
[assembly: AssemblyGitHash(GitHash.hash)]

IntentoSDK/Properties/IntentoSDK.nuspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>IntentoSDK</id>
5-
<version>1.5.4.0</version>
5+
<version>1.5.5.0</version>
66
<authors>Intento</authors>
77
<owners>Intento</owners>
88
<requireLicenseAcceptance>false</requireLicenseAcceptance>
@@ -11,5 +11,6 @@
1111
</metadata>
1212
<files>
1313
<file src="..\bin\IntentoSDK.dll" target="lib\net45" />
14+
<file src="..\bin\IntentoSDK.pdb" target="lib\net45" />
1415
</files>
1516
</package>

0 commit comments

Comments
 (0)