コード例 #1
0
        private bool TestPhrasalVerb(IDictionary <string, Word> result, Word w)
        {
            foreach (var v in _verbs.FindConjugatedVerb(w.Text))
            {
                foreach (var pv in _phrasalVerbs.FindPhrasalVerb(_tokenizer, v.Infinitive))
                {
                    var newWord = new Word();
                    newWord.Text = pv.Presentation;
                    newWord.AddPhrase(w.Phrases.First());
                    AddToList(result, newWord);
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public IEnumerable <Word> Interprete()
        {
            var result        = new Dictionary <string, Word>();
            var currentPhrase = new Phrase();
            var t             = _tokenizer.CurrentToken();
            var wasSpace      = false;

            while (t != null)
            {
                if ((t.IsSpace()) && (!wasSpace))
                {
                    currentPhrase.Text += " ";
                }
                if (!t.IsSpace())
                {
                    currentPhrase.Text += t.Text;
                }
                wasSpace = t.IsSpace();

                if (t.IsWord() && !t.Ignore)
                {
                    var w = new Word();
                    w.Text = t.Text;
                    w.AddPhrase(currentPhrase);
                    if (!TestPhrasalVerb(result, w))
                    {
                        AddToList(result, w);
                    }
                }

                if ((t.Text.Length == 1) && (PhraseEndings.Contains(t.Text)))
                {
                    currentPhrase = new Phrase();
                }


                t = _tokenizer.NextToken();
            }


            return(result.Values);
        }