LastWord() public method

Returns the last word in the phrase.
public LastWord ( ) : WordNode
return WordNode
示例#1
0
 /// <summary>
 /// Determines whether the given phrase indicates an event handler method.
 /// </summary>
 /// <param name="parsedName">The PhraseNode to test.</param>
 /// <returns>True if the phrase indicates an event handler method, False otherwise.</returns>
 protected bool IsEventHandler(PhraseNode parsedName)
 {
     if (parsedName == null || parsedName.Size() == 0)
     {
         return false;
     }
     else
     {
         return IsNonBaseVerb(parsedName.LastWord().Text)
             && parsedName[0].Text.ToLower() != "get"
             && parsedName[0].Text.ToLower() != "set";
     }
 }
示例#2
0
        /// <summary>
        /// Determines whether the given PhraseNode overlaps with the given word.
        /// The two overlap if the last word of the phrase is the same as the given word, 
        /// or if the second-to-last word of the phrase is the same as the given word and the last word of the phrase is ignorable.
        /// </summary>
        /// <param name="name">The phrase to check for overlap.</param>
        /// <param name="word">The word to check for overlap with.</param>
        /// <returns>True if the phrase and word overlap, False otherwise.</returns>
        private bool HasOverlap(PhraseNode name, string word)
        {
            if (name == null || name.Size() == 0 || string.IsNullOrEmpty(word)) { return false; }

            bool hasOverlap = false;
            if (string.Equals(name.LastWord().Text, word, StringComparison.InvariantCultureIgnoreCase))
            {
                //last word of name is same as given word
                hasOverlap = true;
            }
            else if (name.Size() > 1)
            {
                if (string.Equals(name[name.Size() - 2].Text, word, StringComparison.InvariantCultureIgnoreCase) 
                    && PosData.IsIgnorableHeadWord(name.LastWord().Text))
                {
                    //second-to-last word of name is same as given word, and the last word of name is ignorable
                    hasOverlap = true;
                }
            }

            return hasOverlap;
        }