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

Add ability to use localizations for key terms #454

Merged
merged 17 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
switch (file.Format)
{
case FileFormat.Paratext:
yield return new ParatextBackupTermsCorpus(file.Location, ["PN"]);
using (var archive = ZipFile.OpenRead(file.Location))
{
yield return new ZipParatextProjectTermsCorpus(archive, ["PN"]);

Check failure on line 48 in src/Machine/src/Serval.Machine.Shared/Services/CorpusService.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ZipParatextProjectTermsCorpus' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in src/Machine/src/Serval.Machine.Shared/Services/CorpusService.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ZipParatextProjectTermsCorpus' could not be found (are you missing a using directive or an assembly reference?)
}
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ protected override async Task DoWorkAsync(
CancellationToken cancellationToken
)
{
TranslationEngine? engine = await Engines.GetAsync(e => e.EngineId == engineId, cancellationToken);
if (engine is null)
throw new OperationCanceledException($"Engine {engineId} does not exist. Build canceled.");

bool sourceTagInBaseModel = ResolveLanguageCodeForBaseModel(engine.SourceLanguage, out string srcLang);
bool targetTagInBaseModel = ResolveLanguageCodeForBaseModel(engine.TargetLanguage, out string trgLang);

(int trainCount, int pretranslateCount) = await WriteDataFilesAsync(
buildId,
data,
buildOptions,
cancellationToken
);

// Log summary of build data
JsonObject buildPreprocessSummary =
new()
Expand All @@ -65,16 +71,10 @@ CancellationToken cancellationToken
{ "EngineId", engineId },
{ "BuildId", buildId },
{ "NumTrainRows", trainCount },
{ "NumPretranslateRows", pretranslateCount }
{ "NumPretranslateRows", pretranslateCount },
{ "SourceLanguageResolved", srcLang },
{ "TargetLanguageResolved", trgLang }
};
TranslationEngine? engine = await Engines.GetAsync(e => e.EngineId == engineId, cancellationToken);
if (engine is null)
throw new OperationCanceledException($"Engine {engineId} does not exist. Build canceled.");

bool sourceTagInBaseModel = ResolveLanguageCodeForBaseModel(engine.SourceLanguage, out string srcLang);
buildPreprocessSummary.Add("SourceLanguageResolved", srcLang);
bool targetTagInBaseModel = ResolveLanguageCodeForBaseModel(engine.TargetLanguage, out string trgLang);
buildPreprocessSummary.Add("TargetLanguageResolved", trgLang);
Logger.LogInformation("{summary}", buildPreprocessSummary.ToJsonString());

if (trainCount == 0 && (!sourceTagInBaseModel || !targetTagInBaseModel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@
fileNameSuffix: ".USFM",
biblicalTermsListType: "BiblicalTerms",
biblicalTermsProjectName: "",
biblicalTermsFileName: "BiblicalTerms.xml"
biblicalTermsFileName: "BiblicalTerms.xml",
languageCode: "en"

Check failure on line 623 in src/Serval/test/Serval.Translation.Tests/Services/EngineServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build

The best overload for 'ParatextProjectSettings' does not have a parameter named 'languageCode'

Check failure on line 623 in src/Serval/test/Serval.Translation.Tests/Services/EngineServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build

The best overload for 'ParatextProjectSettings' does not have a parameter named 'languageCode'
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@
fileNameSuffix: $"{name}.SFM",
biblicalTermsListType: "Major",
biblicalTermsProjectName: "",
biblicalTermsFileName: "BiblicalTerms.xml"
biblicalTermsFileName: "BiblicalTerms.xml",
languageCode: "en"

Check failure on line 406 in src/Serval/test/Serval.Translation.Tests/Services/PretranslationServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build

The best overload for 'ParatextProjectSettings' does not have a parameter named 'languageCode'

Check failure on line 406 in src/Serval/test/Serval.Translation.Tests/Services/PretranslationServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build

The best overload for 'ParatextProjectSettings' does not have a parameter named 'languageCode'
);
}
}
Expand Down
Loading