Esempio n. 1
0
        //This compares the visitor to another fuzzy visitor and return a Text element containing all terms only
        //contained in this visitor
        public Text TermDifference(TermInjectorTranslationProviderElementTermExtractionVisitor comparisonVisitor)
        {
            Text          termElement = new Text();
            StringBuilder termString  = new StringBuilder();
            Boolean       isNewTerm   = true;

            foreach (var term in this.TermList)
            {
                //If there's a replace field, this has already been handled in the replace visitor
                if (term.Replaces != "")
                {
                    continue;
                }
                isNewTerm = true;
                foreach (var comparisonTerm in comparisonVisitor.TermList)
                {
                    if (term.Translation.Equals(comparisonTerm.Translation))
                    {
                        isNewTerm = false;
                        break;
                    }
                }
                if (isNewTerm)
                {
                    termString.Append(term.Translation + " ");
                }
            }
            termElement.Value = termString.ToString();
            return(termElement);
        }
 public void initializeVisitors()
 {
     //This replaces terms in no match segments
     this.noMatchVisitor = new TermInjectorTranslationProviderElementTermReplacementVisitor(
         this.Options,
         this.exactMatchTrieSource,
         this.regexTrieSource);
     //This collects terms from current segment source
     this.fuzzyCurrentVisitor = new TermInjectorTranslationProviderElementTermExtractionVisitor(
         this.Options,
         this.exactMatchTrieSource,
         this.regexTrieSource);
     //This collects terms from translation suggestion source
     this.fuzzyMatchVisitor = new TermInjectorTranslationProviderElementTermExtractionVisitor(
         this.Options,
         this.exactMatchTrieSource,
         this.regexTrieSource);
     //This replaces terms in fuzzy match segments
     this.fuzzyReplaceVisitor = new TermInjectorTranslationProviderElementTermReplacementVisitor(
         this.Options,
         this.exactMatchTrieReplaces,
         this.regexTrieReplaces);
 }