private bool IsPrepositionalPhrase(PhraseNode parsedName)
 {
     foreach (WordNode word in parsedName.GetPhrase())
     {
         if (word.Tag == PartOfSpeechTag.Preposition)
         {
             return(true);
         }
     }
     return(false);
 }
示例#2
0
        /// <summary>
        /// Tags any word nodes in the given phrase that are prepositions.
        /// </summary>
        /// <param name="phrase">The phrase to tag.</param>
        public void TagPrepostions(PhraseNode phrase)
        {
            if (phrase == null)
            {
                return;
            }

            foreach (var word in phrase.GetPhrase())
            {
                if (pos.IsPreposition(word.Text))
                {
                    word.Tag = PartOfSpeechTag.Preposition;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Tags any word nodes in the given phrase that contain digits.
        /// </summary>
        /// <param name="phrase">The phrase to tag.</param>
        public void TagDigits(PhraseNode phrase)
        {
            if (phrase == null)
            {
                return;
            }

            foreach (var word in phrase.GetPhrase())
            {
                if (Regex.IsMatch(word.Text, @"\d+"))
                {
                    word.Tag = PartOfSpeechTag.Digit;
                }
            }
        }
        public void TestGetPhrase()
        {
            var        wn1   = new WordNode("Eat", PartOfSpeechTag.Verb);
            var        wn2   = new WordNode("More", PartOfSpeechTag.NounModifier);
            var        wn3   = new WordNode("Chicken", PartOfSpeechTag.Noun);
            var        words = new WordNode[] { wn1, wn2, wn3 };
            PhraseNode pn    = new PhraseNode(words, Location.Name, true);

            var phrase = pn.GetPhrase();

            Assert.AreEqual(words.Length, phrase.Count);
            for (int i = 0; i < phrase.Count; i++)
            {
                Assert.AreEqual(pn[i], words[i]);
            }
        }
示例#5
0
        /// <summary>
        /// Finds all the verbs in the given name and adds them to the given preamble.
        /// </summary>
        /// <param name="parsedName">The PhraseNode to gets the verbs from.</param>
        /// <param name="preamble">The preamble PhraseNode to add the verbs to.</param>
        /// <returns>The preamble PhraseNode with the verbs added.</returns>
        private PhraseNode GetVerbPhrase(PhraseNode parsedName, PhraseNode preamble)
        {
            //TODO: should this make a copy of the preamble first?
            PhraseNode phrase = preamble;

            foreach (WordNode word in parsedName.GetPhrase())
            {
                if (word.Tag == PartOfSpeechTag.Verb ||
                    word.Tag == PartOfSpeechTag.VerbModifier ||
                    word.Tag == PartOfSpeechTag.VerbParticle ||
                    word.Tag == PartOfSpeechTag.NonVerb ||
                    word.Tag == PartOfSpeechTag.VerbIgnorable)
                {
                    phrase.Add(word);
                }
            }
            return(phrase);
        }
示例#6
0
        public void TestGetPhrase() {
            var wn1 = new WordNode("Eat", PartOfSpeechTag.Verb);
            var wn2 = new WordNode("More", PartOfSpeechTag.NounModifier);
            var wn3 = new WordNode("Chicken", PartOfSpeechTag.Noun);
            var words = new WordNode[] {wn1, wn2, wn3};
            PhraseNode pn = new PhraseNode(words, Location.Name, true);

            var phrase = pn.GetPhrase();
            Assert.AreEqual(words.Length, phrase.Count);
            for(int i = 0; i < phrase.Count; i++) {
                Assert.AreEqual(pn[i], words[i]);
            }
        }