From d98066136d482b4194b956d06dc941a2e2f4c6cd Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 31 Oct 2024 12:14:33 -0400 Subject: [PATCH] More progress --- .../Corpora/NParallelTextCorpus.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/SIL.Machine/Corpora/NParallelTextCorpus.cs b/src/SIL.Machine/Corpora/NParallelTextCorpus.cs index de325b31..78cfe606 100644 --- a/src/SIL.Machine/Corpora/NParallelTextCorpus.cs +++ b/src/SIL.Machine/Corpora/NParallelTextCorpus.cs @@ -88,7 +88,11 @@ public override IEnumerable GetRows(IEnumerable textId private bool AnyInRangeWithSegments(IList rows) { - return rows.Any(r => r.IsInRange) && rows.All(r => !(r.IsInRange && r.Segment.Count == 0)); + return rows.Any(r => r.IsInRange) + && ( + rows.Except(rows.Where(r => r.IsInRange && r.Segment.Count > 0)).Any(r => !r.IsInRange) + || rows.All(r => r.IsInRange && r.Segment.Count > 0) + ); } private IList MinRefIndexes(IList refs) @@ -149,10 +153,6 @@ private IEnumerable GetRows(IList> listOf if (minRefIndexes.Count < (N - completed.Count(c => c))) //then there are some non-min refs { - IReadOnlyList allNonMinRows = nonMinRefIndexes - .Select(i => AllRowsList[i]) - .ToImmutableArray(); - IList> minEnumerators = minRefIndexes .Select(i => listOfEnumerators[i]) .ToList(); @@ -160,7 +160,16 @@ private IEnumerable GetRows(IList> listOf .Select(i => listOfEnumerators[i]) .ToList(); - if (!allNonMinRows.Any() && minEnumerators.Select(e => e.Current.IsInRange).Any()) + if ( + minRefIndexes + .Select(i => + !AllRowsList[i] + && minRefIndexes + .Select(j => j != i && !completed[i] && listOfEnumerators[i].Current.IsInRange) + .Any(b => b) + ) + .Any(b => b) + ) { if ( rangeInfo.IsInRange