From 2058d4d0a78c9132e08f1e3a3d840f20f8a1b8e1 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Fri, 15 Nov 2024 10:27:51 -0500 Subject: [PATCH] Change mergedtextcorpus parameter --- src/SIL.Machine/Corpora/CorporaExtensions.cs | 12 ++---------- src/SIL.Machine/Corpora/MergedTextCorpus.cs | 9 +++++++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/SIL.Machine/Corpora/CorporaExtensions.cs b/src/SIL.Machine/Corpora/CorporaExtensions.cs index 33186799..f5e1b4b1 100644 --- a/src/SIL.Machine/Corpora/CorporaExtensions.cs +++ b/src/SIL.Machine/Corpora/CorporaExtensions.cs @@ -544,20 +544,12 @@ public static ITextCorpus ChooseRandom( int seed ) { - return new MergedTextCorpus( - new NParallelTextCorpus(corpora) { AllRows = allRows.ToArray() }, - MergeRule.Random, - seed - ); + return new MergedTextCorpus(corpora, allRows.ToArray(), MergeRule.Random, seed); } public static ITextCorpus ChooseFirst(this IEnumerable corpora, IEnumerable allRows) { - return new MergedTextCorpus( - new NParallelTextCorpus(corpora) { AllRows = allRows.ToArray() }, - MergeRule.First, - 0 - ); + return new MergedTextCorpus(corpora, allRows.ToArray(), MergeRule.First, 0); } #endregion diff --git a/src/SIL.Machine/Corpora/MergedTextCorpus.cs b/src/SIL.Machine/Corpora/MergedTextCorpus.cs index 890f7e10..1bcbf822 100644 --- a/src/SIL.Machine/Corpora/MergedTextCorpus.cs +++ b/src/SIL.Machine/Corpora/MergedTextCorpus.cs @@ -13,9 +13,14 @@ public class MergedTextCorpus : TextCorpusBase private readonly Random _random; - public MergedTextCorpus(NParallelTextCorpus nParallelTextCorpus, MergeRule mergeRule, int seed) + public MergedTextCorpus( + IEnumerable corpora, + IEnumerable allRows, + MergeRule mergeRule, + int seed + ) { - _corpus = nParallelTextCorpus; + _corpus = new NParallelTextCorpus(corpora) { AllRows = allRows.ToList() }; _mergeRule = mergeRule; _random = new Random(seed); }