From 6f0b6c5f845267ecadbe53132b45210b7655b06e Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 9 Jan 2025 15:54:06 -0500 Subject: [PATCH] Change alignment data structure --- .../Translation/WordAlignmentResult.cs | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/SIL.Machine/Translation/WordAlignmentResult.cs b/src/SIL.Machine/Translation/WordAlignmentResult.cs index 01f7fb72..35dec052 100644 --- a/src/SIL.Machine/Translation/WordAlignmentResult.cs +++ b/src/SIL.Machine/Translation/WordAlignmentResult.cs @@ -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 { @@ -10,39 +10,18 @@ public WordAlignmentResult( IEnumerable sourceTokens, IEnumerable targetTokens, IEnumerable confidences, - WordAlignmentMatrix alignment + IEnumerable 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 SourceTokens { get; } public IReadOnlyList TargetTokens { get; } public IReadOnlyList Confidences { get; } - public WordAlignmentMatrix Alignment { get; } + public IEnumerable AlignedWordPairs { get; } } }