コード例 #1
0
        private int FindPreviousHead(int headIdx, Tree[] daughterTrees, bool origWasInterjection)
        {
            bool seenSeparator = false;
            int  newHeadIdx    = headIdx;

            while (newHeadIdx >= 0)
            {
                newHeadIdx = newHeadIdx - 1;
                if (newHeadIdx < 0)
                {
                    return(newHeadIdx);
                }
                string label = Tlp.BasicCategory(daughterTrees[newHeadIdx].Value());
                if (PartsOfSpeech.Comma.Equals(label) || PartsOfSpeech.ColonSemiColon.Equals(label))
                {
                    seenSeparator = true;
                }
                else if (daughterTrees[newHeadIdx].IsPreTerminal() &&
                         (Tlp.IsPunctuationTag(label) || !origWasInterjection && PartsOfSpeech.Interjection.Equals(label)) ||
                         INTJ.Equals(label) && !origWasInterjection)
                {
                    // keep looping
                }
                else
                {
                    if (!seenSeparator)
                    {
                        newHeadIdx = -1;
                    }
                    break;
                }
            }
            return(newHeadIdx);
        }
コード例 #2
0
 private bool ShouldSkip(Tree t, bool origWasInterjection)
 {
     return(t.IsPreTerminal() &&
            (Tlp.IsPunctuationTag(t.Value()) || !origWasInterjection && PartsOfSpeech.Interjection.Equals(t.Value())) ||
            INTJ.Equals(t.Value()) && !origWasInterjection);
 }