示例#1
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);
        }