예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// Returns a PhraseNode containing the noun phrase words from the given name, starting from startIndex.
        /// All noun phrase words prior to the first encountered preposition are included.
        /// </summary>
        /// <param name="parsedName">The PhraseNode to get the noun phrase from.</param>
        /// <param name="startIndex">The index of the word to start from.</param>
        private PhraseNode GetNounPhrase(PhraseNode parsedName, int startIndex)
        {
            PhraseNode phrase = parsedName.GetNewEmpty();

            for (int i = startIndex; i < parsedName.Size(); i++)
            {
                PartOfSpeechTag tag = parsedName[i].Tag;
                if (tag == PartOfSpeechTag.Noun ||
                    tag == PartOfSpeechTag.NounModifier ||
                    tag == PartOfSpeechTag.Determiner ||
                    tag == PartOfSpeechTag.Pronoun ||
                    tag == PartOfSpeechTag.NounIgnorable ||
                    tag == PartOfSpeechTag.Digit ||
                    tag == PartOfSpeechTag.Preamble)
                {
                    phrase.Add(parsedName[i]);
                }
                else if (tag == PartOfSpeechTag.Preposition)
                {
                    break;
                }
            }
            return(phrase);
        }