ABB.Swum.UnigramMethodRule.HasOverlap C# (CSharp) Метод

HasOverlap() приватный Метод

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.
private HasOverlap ( PhraseNode name, string word ) : bool
name ABB.Swum.Nodes.PhraseNode The phrase to check for overlap.
word string The word to check for overlap with.
Результат bool
        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;
        }