Esempio n. 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);
        }
Esempio n. 2
0
 protected override int PostOperationFix(int headIdx, Tree[] daughterTrees)
 {
     if (headIdx >= 2)
     {
         string prevLab = Tlp.BasicCategory(daughterTrees[headIdx - 1].Value());
         if (prevLab.Equals(PartsOfSpeech.CoordinatingConjunction) || prevLab.Equals(AbstractCollinsHeadFinder.CONJP))
         {
             int  newHeadIdx = headIdx - 2;
             Tree t          = daughterTrees[newHeadIdx];
             while (newHeadIdx >= 0 && t.IsPreTerminal() &&
                    Tlp.IsPunctuationTag(t.Value()))
             {
                 newHeadIdx--;
             }
             if (newHeadIdx >= 0)
             {
                 headIdx = newHeadIdx;
             }
         }
     }
     return(headIdx);
 }
Esempio n. 3
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);
 }