Ejemplo n.º 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()));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }