internal InteractiveTranslationSession(TranslationEngine engine, string[] sourceSegment,
                                        double confidenceThreshold, HybridInteractiveTranslationResult result)
 {
     _engine    = engine;
     _suggester = new PhraseTranslationSuggester {
         ConfidenceThreshold = confidenceThreshold
     };
     SourceSegment = sourceSegment;
     RuleResult    = result.RuleResult;
     SmtWordGraph  = result.SmtWordGraph;
 }
Exemplo n.º 2
0
        public void TranslateInteractively(string sourceSegment, double confidenceThreshold,
                                           Action <InteractiveTranslationSession> onFinished)
        {
            string[] tokens = SourceWordTokenizer.TokenizeToStrings(sourceSegment).ToArray();
            if (tokens.Length > MaxSegmentSize)
            {
                var results = new HybridInteractiveTranslationResult(new WordGraph(), null);
                onFinished(new InteractiveTranslationSession(this, tokens, confidenceThreshold, results));
                return;
            }

            Task <HybridInteractiveTranslationResult> task = RestClient.TranslateInteractivelyAsync(ProjectId, tokens);

            task.ContinueWith(t => onFinished(t.IsFaulted ? null
                                : new InteractiveTranslationSession(this, tokens, confidenceThreshold, t.Result)));
        }