public static WordAlignmentMatrix GetBestAlignment(this ISegmentAligner aligner, ParallelTextSegment segment, Func <string, string> sourcePreprocessor = null, Func <string, string> targetPreprocessor = null) { IReadOnlyList <string> sourceSegment = segment.SourceSegment.Preprocess(sourcePreprocessor); IReadOnlyList <string> targetSegment = segment.TargetSegment.Preprocess(targetPreprocessor); return(aligner.GetBestAlignment(sourceSegment, targetSegment, segment.CreateAlignmentMatrix())); }
public static string GetGizaFormatString(this ISegmentAligner aligner, ParallelTextSegment segment, Func <string, string> sourcePreprocessor = null, Func <string, string> targetPreprocessor = null, bool isUnknown = true) { IReadOnlyList <string> sourceSegment = segment.SourceSegment.Preprocess(sourcePreprocessor); IReadOnlyList <string> targetSegment = segment.TargetSegment.Preprocess(targetPreprocessor); WordAlignmentMatrix alignment = aligner.GetBestAlignment(sourceSegment, targetSegment, segment.CreateAlignmentMatrix(isUnknown)); return(alignment.ToGizaFormat(sourceSegment, targetSegment)); }
public static void AddSegmentPair(this IWordAlignmentModel model, ParallelTextSegment segment, Func <string, string> sourcePreprocessor = null, Func <string, string> targetPreprocessor = null, bool isUnknown = true) { if (segment.IsEmpty) { return; } IReadOnlyList <string> sourceTokens = segment.SourceSegment.Preprocess(sourcePreprocessor); IReadOnlyList <string> targetTokens = segment.TargetSegment.Preprocess(targetPreprocessor); model.AddSegmentPair(sourceTokens, targetTokens, segment.CreateAlignmentMatrix(isUnknown)); }
public static string GetAlignmentString(this IWordAlignmentModel model, ParallelTextSegment segment, bool includeProbs, Func <string, string> sourcePreprocessor = null, Func <string, string> targetPreprocessor = null) { IReadOnlyList <string> sourceSegment = segment.SourceSegment.Preprocess(sourcePreprocessor); IReadOnlyList <string> targetSegment = segment.TargetSegment.Preprocess(targetPreprocessor); WordAlignmentMatrix alignment = model.GetBestAlignment(sourceSegment, targetSegment, segment.CreateAlignmentMatrix()); if (includeProbs) { return(alignment.ToString(model, sourceSegment, targetSegment)); } return(alignment.ToString()); }