Skip to content

Commit

Permalink
Updated parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Oct 29, 2024
1 parent 15e894d commit 5e6d647
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/Serval/src/Serval.Translation/Services/EngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ private V1.ParallelCorpus Map(
Corpus source,
TrainingCorpus? trainingCorpus,
PretranslateCorpus? pretranslateCorpus,
bool noTrainingCorpusFilter,
bool noPretranslateCorpusFilter
bool trainOnAllCorpora,
bool pretranslateOnAllCorpora
)
{
IEnumerable<V1.CorpusFile> sourceFiles = source.SourceFiles.Select(Map);
Expand All @@ -641,7 +641,7 @@ bool noPretranslateCorpusFilter
new() { Language = source.TargetLanguage, Files = { source.TargetFiles.Select(Map) } };

if (
noTrainingCorpusFilter
trainOnAllCorpora
|| (trainingCorpus is not null && trainingCorpus.TextIds is null && trainingCorpus.ScriptureRange is null)
)
{
Expand Down Expand Up @@ -684,7 +684,7 @@ bool noPretranslateCorpusFilter
}
}
if (
noPretranslateCorpusFilter
pretranslateOnAllCorpora
|| (
pretranslateCorpus is not null
&& pretranslateCorpus.TextIds is null
Expand Down Expand Up @@ -739,23 +739,23 @@ private V1.ParallelCorpus Map(
Models.ParallelCorpus source,
TrainingCorpus? trainingCorpus,
PretranslateCorpus? pretranslateCorpus,
bool noTrainingCorpusFilter,
bool noPretranslateCorpusFilter
bool trainOnAllCorpora,
bool pretranslateOnAllCorpora
)
{
string? referenceFileLocation =
source.TargetCorpora.Count > 0 && source.TargetCorpora[0].Files.Count > 0
? Map(source.TargetCorpora[0].Files[0]).Location
: null;

bool sourceTrainOnAll =
noTrainingCorpusFilter || (trainingCorpus is not null && trainingCorpus.SourceFilters is null);
bool sourcePretranslateAll =
noPretranslateCorpusFilter || (pretranslateCorpus is not null && pretranslateCorpus.SourceFilters is null);
bool trainOnAllSources =
trainOnAllCorpora || (trainingCorpus is not null && trainingCorpus.SourceFilters is null);
bool pretranslateAllSources =
pretranslateOnAllCorpora || (pretranslateCorpus is not null && pretranslateCorpus.SourceFilters is null);

bool targetTrainOnAll =
noTrainingCorpusFilter || (trainingCorpus is not null && trainingCorpus.TargetFilters is null);
bool targetPretranslateAll = noPretranslateCorpusFilter || pretranslateCorpus is not null; // there is no pretranslate Target filter.
bool trainOnAllTargets =
trainOnAllCorpora || (trainingCorpus is not null && trainingCorpus.TargetFilters is null);
bool pretranslateAllTargets = pretranslateOnAllCorpora || pretranslateCorpus is not null; // there is no pretranslate Target filter.

return new V1.ParallelCorpus
{
Expand All @@ -768,8 +768,8 @@ bool noPretranslateCorpusFilter
trainingCorpus?.SourceFilters?.Where(sf => sf.CorpusRef == sc.Id).FirstOrDefault(),
pretranslateCorpus?.SourceFilters?.Where(sf => sf.CorpusRef == sc.Id).FirstOrDefault(),
referenceFileLocation,
sourceTrainOnAll,
sourcePretranslateAll
trainOnAllSources,
pretranslateAllSources
)
)
},
Expand All @@ -781,16 +781,16 @@ bool noPretranslateCorpusFilter
trainingCorpus?.TargetFilters?.Where(sf => sf.CorpusRef == tc.Id).FirstOrDefault(),
null,
referenceFileLocation,
targetTrainOnAll,
targetPretranslateAll
trainOnAllTargets,
pretranslateAllTargets
)
)
}
};
}

private V1.MonolingualCorpus Map(
Models.MonolingualCorpus source,
Models.MonolingualCorpus inputCorpus,
ParallelCorpusFilter? trainingFilter,
ParallelCorpusFilter? pretranslateFilter,
string? referenceFileLocation,
Expand Down Expand Up @@ -836,26 +836,26 @@ pretranslateFilter is not null
.ToDictionary();
}

var corpus = new V1.MonolingualCorpus
var returnCorpus = new V1.MonolingualCorpus
{
Id = source.Id,
Language = source.Language,
Files = { source.Files.Select(Map) }
Id = inputCorpus.Id,
Language = inputCorpus.Language,
Files = { inputCorpus.Files.Select(Map) }
};

if (
trainOnAll
|| (trainingFilter is not null && trainingFilter.TextIds is null && trainingFilter.ScriptureRange is null)
)
{
corpus.TrainOnAll = true;
returnCorpus.TrainOnAll = true;
}
else
{
if (trainOnChapters is not null)
corpus.TrainOnChapters.Add(trainOnChapters);
returnCorpus.TrainOnChapters.Add(trainOnChapters);
if (trainingFilter?.TextIds is not null)
corpus.TrainOnTextIds.Add(trainingFilter.TextIds);
returnCorpus.TrainOnTextIds.Add(trainingFilter.TextIds);
}

if (
Expand All @@ -867,17 +867,17 @@ pretranslateFilter is not null
)
)
{
corpus.PretranslateAll = true;
returnCorpus.PretranslateAll = true;
}
else
{
if (pretranslateChapters is not null)
corpus.PretranslateChapters.Add(pretranslateChapters);
returnCorpus.PretranslateChapters.Add(pretranslateChapters);
if (pretranslateFilter?.TextIds is not null)
corpus.PretranslateTextIds.Add(pretranslateFilter.TextIds);
returnCorpus.PretranslateTextIds.Add(pretranslateFilter.TextIds);
}

return corpus;
return returnCorpus;
}

private V1.CorpusFile Map(Models.CorpusFile source)
Expand Down

0 comments on commit 5e6d647

Please sign in to comment.