diff --git a/src/Serval/src/Serval.Translation/Services/EngineService.cs b/src/Serval/src/Serval.Translation/Services/EngineService.cs index 6c8c3059..ac275cfb 100644 --- a/src/Serval/src/Serval.Translation/Services/EngineService.cs +++ b/src/Serval/src/Serval.Translation/Services/EngineService.cs @@ -777,14 +777,29 @@ pretranslateFilter is not null Files = { source.Files.Select(Map) } }; - if (trainOnChapters is not null) - corpus.TrainOnChapters.Add(trainOnChapters); - if (trainingFilter?.TextIds is not null) - corpus.TrainOnTextIds.Add(trainingFilter.TextIds); - if (pretranslateChapters is not null) - corpus.PretranslateChapters.Add(pretranslateChapters); - if (pretranslateFilter?.TextIds is not null) - corpus.PretranslateTextIds.Add(pretranslateFilter.TextIds); + if (trainingFilter is null) + { + corpus.TrainOnAll = true; + } + else + { + if (trainOnChapters is not null) + corpus.TrainOnChapters.Add(trainOnChapters); + if (trainingFilter?.TextIds is not null) + corpus.TrainOnTextIds.Add(trainingFilter.TextIds); + } + + if (pretranslateFilter is null) + { + corpus.PretranslateAll = true; + } + else + { + if (pretranslateChapters is not null) + corpus.PretranslateChapters.Add(pretranslateChapters); + if (pretranslateFilter?.TextIds is not null) + corpus.PretranslateTextIds.Add(pretranslateFilter.TextIds); + } return corpus; } diff --git a/src/Serval/test/Serval.E2ETests/ServalApiTests.cs b/src/Serval/test/Serval.E2ETests/ServalApiTests.cs index 0589e53b..5bca5c05 100644 --- a/src/Serval/test/Serval.E2ETests/ServalApiTests.cs +++ b/src/Serval/test/Serval.E2ETests/ServalApiTests.cs @@ -137,8 +137,8 @@ public async Task NmtQueueMultiple() engineIds[i] = await _helperClient.CreateNewEngineAsync("Nmt", "es", "en", $"NMT1_{i}"); string engineId = engineIds[i]; string[] books = ["MAT.txt", "1JN.txt", "2JN.txt"]; - await _helperClient.AddTextCorpusToEngineAsync(engineId, books, "es", "en", false); - await _helperClient.AddTextCorpusToEngineAsync(engineId, ["3JN.txt"], "es", "en", true); + await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, books, "es", "en", false); + await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, ["3JN.txt"], "es", "en", true); await _helperClient.StartBuildAsync(engineId); //Ensure that tasks are enqueued roughly in order await Task.Delay(1_000); @@ -247,7 +247,7 @@ public async Task CircuitousRouteGetWordGraphAsync() Assert.That(ex.StatusCode, Is.EqualTo(409)); //Add corpus - string cId = await _helperClient.AddTextCorpusToEngineAsync( + string cId = await _helperClient.AddParallelTextCorpusToEngineAsync( smtEngineId, ["2JN.txt", "3JN.txt"], "es", @@ -259,10 +259,10 @@ public async Task CircuitousRouteGetWordGraphAsync() await _helperClient.BuildEngineAsync(smtEngineId); //Remove added corpus (shouldn't affect translation) - await _helperClient.TranslationEnginesClient.DeleteCorpusAsync(smtEngineId, cId, deleteFiles: false); + await _helperClient.TranslationEnginesClient.DeleteParallelCorpusAsync(smtEngineId, cId); // Add corpus - await _helperClient.AddTextCorpusToEngineAsync( + await _helperClient.AddParallelTextCorpusToEngineAsync( smtEngineId, ["1JN.txt", "2JN.txt", "3JN.txt"], "es", diff --git a/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs b/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs index 31c971e9..d64fb15a 100644 --- a/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs +++ b/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs @@ -295,7 +295,7 @@ bool pretranslate if (pretranslate) { TranslationBuildConfig.Pretranslate!.Add( - new PretranslateCorpusConfig { CorpusId = parallelCorpus.Id, TextIds = filesToAdd.ToList() } + new PretranslateCorpusConfig { ParallelCorpusId = parallelCorpus.Id, TextIds = filesToAdd.ToList() } ); }