예제 #1
0
        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()));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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());
        }