public void AddSegmentPair(IReadOnlyList <string> sourceSegment, IReadOnlyList <string> targetSegment, WordAlignmentMatrix hintMatrix = null) { _directWordAlignmentModel.AddSegmentPair(sourceSegment, targetSegment, hintMatrix); WordAlignmentMatrix invertedHintMatrix = hintMatrix?.Clone(); invertedHintMatrix?.Transpose(); _inverseWordAlignmentModel.AddSegmentPair(targetSegment, sourceSegment, invertedHintMatrix); }
public static WordAlignmentMatrix GetBestAlignment(this ISegmentAligner aligner, IReadOnlyList <string> sourceSegment, IReadOnlyList <string> targetSegment, WordAlignmentMatrix knownAlignment) { WordAlignmentMatrix estimatedAlignment = aligner.GetBestAlignment(sourceSegment, targetSegment); WordAlignmentMatrix alignment = estimatedAlignment; if (knownAlignment != null) { alignment = knownAlignment.Clone(); alignment.PrioritySymmetrizeWith(estimatedAlignment); } return(alignment); }
public WordAlignmentMatrix GetBestAlignment(IReadOnlyList <string> sourceSegment, IReadOnlyList <string> targetSegment, WordAlignmentMatrix hintMatrix = null) { WordAlignmentMatrix matrix = _srcTrgAligner.GetBestAlignment(sourceSegment, targetSegment, hintMatrix); WordAlignmentMatrix invHintMatrix = null; if (hintMatrix != null) { invHintMatrix = hintMatrix.Clone(); invHintMatrix.Transpose(); } WordAlignmentMatrix invMatrix = _trgSrcAligner.GetBestAlignment(targetSegment, sourceSegment, invHintMatrix); invMatrix.Transpose(); matrix.SymmetrizeWith(invMatrix); return(matrix); }