Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key terms support #229

Merged
merged 12 commits into from
Dec 6, 2023
6 changes: 4 additions & 2 deletions src/Serval.Client/Client.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,8 @@ public partial interface ITranslationEnginesClient
/// <br/>
/// <br/>The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON object.
/// <br/>A typical use case would be to set `"options"` to `{"max_steps":10}` in order to configure the maximum
/// <br/>number of training iterations in order to reduce turnaround time for testing purposes.
/// <br/>number of training iterations in order to reduce turnaround time for testing purposes. See [this](https://github.com/sillsdev/serval/wiki/Paratext-Key-Terms-Parsing)
/// <br/>for another use of the `"options"` parameter: excluding Paratext key terms data. (By default, Paratext key terms data will be incorporated and used for training).
/// </remarks>
/// <param name="id">The translation engine id</param>
/// <param name="buildConfig">The build config (see remarks)</param>
Expand Down Expand Up @@ -2920,7 +2921,8 @@ public string BaseUrl
/// <br/>
/// <br/>The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON object.
/// <br/>A typical use case would be to set `"options"` to `{"max_steps":10}` in order to configure the maximum
/// <br/>number of training iterations in order to reduce turnaround time for testing purposes.
/// <br/>number of training iterations in order to reduce turnaround time for testing purposes. See [this](https://github.com/sillsdev/serval/wiki/Paratext-Key-Terms-Parsing)
/// <br/>for another use of the `"options"` parameter: excluding Paratext key terms data. (By default, Paratext key terms data will be incorporated and used for training).
/// </remarks>
/// <param name="id">The translation engine id</param>
/// <param name="buildConfig">The build config (see remarks)</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,8 @@ CancellationToken cancellationToken
///
/// The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON object.
/// A typical use case would be to set `"options"` to `{"max_steps":10}` in order to configure the maximum
/// number of training iterations in order to reduce turnaround time for testing purposes.
/// number of training iterations in order to reduce turnaround time for testing purposes. See [this](https://github.com/sillsdev/serval/wiki/Paratext-Key-Terms-Parsing)
/// for another use of the `"options"` parameter: excluding Paratext key terms data. (By default, Paratext key terms data will be incorporated and used for training).
/// </remarks>
/// <param name="id">The translation engine id</param>
/// <param name="buildConfig">The build config (see remarks)</param>
Expand Down
54 changes: 39 additions & 15 deletions tests/Serval.E2ETests/ServalApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,34 +356,58 @@ async Task StartAndCancelTwice(string engineId)
public async Task ParatextProjectNmtJobAsync()
{
await _helperClient!.ClearEngines();
DataFile file = await _helperClient.dataFilesClient.CreateAsync(
new FileParameter(data: File.OpenRead("../../../data/TestProject.zip")),
FileFormat.Paratext
);
string engineId = await _helperClient.CreateNewEngine("Nmt", "en", "es", "NMT4");
await _helperClient.AddTextCorpusToEngine(
engineId,
new string[] { "1JN.txt", "2JN.txt", "3JN.txt" },
"en",
"es",
false
);
string tempDirectory = Path.GetTempPath();
DataFile file1,
file2;
try
{
ZipFile.CreateFromDirectory(
Path.Combine("..", "..", "..", "data", "TestProject"),
Path.Combine(tempDirectory, "TestProject.zip")
);
ZipFile.CreateFromDirectory(
Path.Combine("..", "..", "..", "data", "TestProjectTarget"),
Path.Combine(tempDirectory, "TestProjectTarget.zip")
);

file1 = await _helperClient.dataFilesClient.CreateAsync(
new FileParameter(data: File.OpenRead(Path.Combine(tempDirectory, "TestProject.zip"))),
FileFormat.Paratext
);
file2 = await _helperClient.dataFilesClient.CreateAsync(
new FileParameter(data: File.OpenRead(Path.Combine(tempDirectory, "TestProjectTarget.zip"))),
FileFormat.Paratext
);
}
finally
{
File.Delete(Path.Combine(tempDirectory, "TestProject.zip"));
File.Delete(Path.Combine(tempDirectory, "TestProjectTarget.zip"));
}

string engineId = await _helperClient.CreateNewEngine("Nmt", "en", "sbp", "NMT4");

TranslationCorpus corpus = await _helperClient.translationEnginesClient.AddCorpusAsync(
engineId,
new TranslationCorpusConfig
{
SourceLanguage = "en",
TargetLanguage = "es",
TargetLanguage = "sbp",
SourceFiles = new TranslationCorpusFileConfig[]
{
new TranslationCorpusFileConfig { FileId = file.Id }
new TranslationCorpusFileConfig { FileId = file1.Id }
},
TargetFiles = new TranslationCorpusFileConfig[] { }
TargetFiles = new TranslationCorpusFileConfig[]
{
new TranslationCorpusFileConfig { FileId = file2.Id }
}
}
);
_helperClient.TranslationBuildConfig.Pretranslate!.Add(
new PretranslateCorpusConfig { CorpusId = corpus.Id, TextIds = new string[] { "JHN", "REV" } }
);
_helperClient.TranslationBuildConfig.Options = "{\"max_steps\":10, \"use_key_terms\":true}";

await _helperClient.BuildEngine(engineId);
Assert.That(
(await _helperClient.translationEnginesClient.GetAllBuildsAsync(engineId)).First().State
Expand Down
1 change: 1 addition & 0 deletions tests/Serval.E2ETests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
global using System.Text.Json;
global using NUnit.Framework;
global using Serval.Client;
global using System.IO.Compression;
Binary file removed tests/Serval.E2ETests/data/TestProject.zip
Binary file not shown.
Loading
Loading