Skip to content

Commit

Permalink
Change alignment data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkidu93 committed Jan 9, 2025
1 parent f905c2d commit 6f0b6c5
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions src/SIL.Machine/Translation/WordAlignmentResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using SIL.Machine.Corpora;

namespace SIL.Machine.Translation
{
Expand All @@ -10,39 +10,18 @@ public WordAlignmentResult(
IEnumerable<string> sourceTokens,
IEnumerable<string> targetTokens,
IEnumerable<double> confidences,
WordAlignmentMatrix alignment
IEnumerable<AlignedWordPair> alignedWordPairs
)
{
SourceTokens = sourceTokens.ToArray();
TargetTokens = targetTokens.ToArray();
Confidences = confidences.ToArray();
if (Confidences.Count != TargetTokens.Count)
{
throw new ArgumentException(
"The confidences must be the same length as the target segment.",
nameof(confidences)
);
}
Alignment = alignment;
if (Alignment.RowCount != SourceTokens.Count)
{
throw new ArgumentException(
"The alignment source length must be the same length as the source segment.",
nameof(alignment)
);
}
if (Alignment.ColumnCount != TargetTokens.Count)
{
throw new ArgumentException(
"The alignment target length must be the same length as the target segment.",
nameof(alignment)
);
}
AlignedWordPairs = alignedWordPairs;
}

public IReadOnlyList<string> SourceTokens { get; }
public IReadOnlyList<string> TargetTokens { get; }
public IReadOnlyList<double> Confidences { get; }
public WordAlignmentMatrix Alignment { get; }
public IEnumerable<AlignedWordPair> AlignedWordPairs { get; }
}
}

0 comments on commit 6f0b6c5

Please sign in to comment.