Skip to content

Commit

Permalink
Only allow textId or scriptureRange in a buildID. (#401)
Browse files Browse the repository at this point in the history
* one, but not both.

* from review
  • Loading branch information
johnml1135 authored Jun 10, 2024
1 parent 7dcbb5c commit 68a0374
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Serval.Translation/Services/EngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ Dictionary<string, List<int>> GetChapters(V1.Corpus corpus, string scriptureRang
{
corpus.PretranslateAll =
pretranslateCorpus.TextIds is null && pretranslateCorpus.ScriptureRange is null;
if (pretranslateCorpus.TextIds is not null && pretranslateCorpus.ScriptureRange is not null)
{
throw new InvalidOperationException(
$"The corpus {c.Id} cannot specify both 'textIds' and 'scriptureRange' for 'pretranslate'."
);
}
if (pretranslateCorpus.TextIds is not null)
corpus.PretranslateTextIds.Add(pretranslateCorpus.TextIds);
if (!string.IsNullOrEmpty(pretranslateCorpus.ScriptureRange))
Expand Down Expand Up @@ -262,6 +268,12 @@ Dictionary<string, List<int>> GetChapters(V1.Corpus corpus, string scriptureRang
if (trainOn?.TryGetValue(c.Id, out TrainingCorpus? trainingCorpus) ?? false)
{
corpus.TrainOnAll = trainingCorpus.TextIds is null && trainingCorpus.ScriptureRange is null;
if (trainingCorpus.TextIds is not null && trainingCorpus.ScriptureRange is not null)
{
throw new InvalidOperationException(
$"The corpus {c.Id} cannot specify both 'textIds' and 'scriptureRange' for trainOn"
);
}
if (trainingCorpus.TextIds is not null)
corpus.TrainOnTextIds.Add(trainingCorpus.TextIds);
if (!string.IsNullOrEmpty(trainingCorpus.ScriptureRange))
Expand Down

0 comments on commit 68a0374

Please sign in to comment.