Skip to content

Commit

Permalink
More progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkidu93 committed Oct 31, 2024
1 parent e76177c commit d980661
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/SIL.Machine/Corpora/NParallelTextCorpus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ public override IEnumerable<NParallelTextRow> GetRows(IEnumerable<string> textId

private bool AnyInRangeWithSegments(IList<TextRow> 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<int> MinRefIndexes(IList<object> refs)
Expand Down Expand Up @@ -149,18 +153,23 @@ private IEnumerable<NParallelTextRow> GetRows(IList<IEnumerator<TextRow>> listOf

if (minRefIndexes.Count < (N - completed.Count(c => c))) //then there are some non-min refs
{
IReadOnlyList<bool> allNonMinRows = nonMinRefIndexes
.Select(i => AllRowsList[i])
.ToImmutableArray();

IList<IEnumerator<TextRow>> minEnumerators = minRefIndexes
.Select(i => listOfEnumerators[i])
.ToList();
IList<IEnumerator<TextRow>> nonMinEnumerators = nonMinRefIndexes
.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
Expand Down

0 comments on commit d980661

Please sign in to comment.