Exemplo 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()));
        }
Exemplo n.º 2
0
 public ThotSmtEngine(ThotSmtModel smtModel)
 {
     _smtModel = smtModel;
     _sessions = new HashSet <ThotInteractiveTranslationSession>();
     LoadHandle();
     _segmentAligner      = new FuzzyEditDistanceSegmentAligner(GetTranslationProbability);
     _confidenceEstimator = new Ibm1WordConfidenceEstimator(GetTranslationProbability);
     //_confidenceEstimator = new WppWordConfidenceEstimator(this);
     ErrorCorrectionModel = new ErrorCorrectionModel();
 }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        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 SymmetrizedSegmentAligner(ISegmentAligner srcTrgAligner, ISegmentAligner trgSrcAligner)
 {
     _srcTrgAligner = srcTrgAligner;
     _trgSrcAligner = trgSrcAligner;
 }