예제 #1
0
        public virtual IList <Sieve.MentionData> FindClosestMentionsInSpanBackward(Pair <int, int> span)
        {
            IList <Sieve.MentionData> mentions = new List <Sieve.MentionData>();
            Pair <int, int>           currSpan = span;

            while (true)
            {
                Sieve.MentionData mentionData = FindClosestMentionInSpanBackward(currSpan);
                if (mentionData != null)
                {
                    mentions.Add(mentionData);
                    currSpan.second = mentionData.begin - 1;
                }
                else
                {
                    return(mentions);
                }
            }
        }
예제 #2
0
        public virtual IList <Sieve.MentionData> FindClosestMentionsInSpanForward(Pair <int, int> span)
        {
            IList <Sieve.MentionData> mentions = new List <Sieve.MentionData>();
            Pair <int, int>           currSpan = span;

            while (true)
            {
                Sieve.MentionData mention = FindClosestMentionInSpanForward(currSpan);
                if (mention != null)
                {
                    mentions.Add(mention);
                    currSpan.first = mention.end + 1;
                }
                else
                {
                    return(mentions);
                }
            }
        }
예제 #3
0
        public virtual Sieve.MentionData FindClosestMentionInSpanBackward(Pair <int, int> span)
        {
            IList <int> pronounIndices           = ScanForPronouns(span);
            IList <Pair <int, int> > nameIndices = ScanForNamesNew(span).second;
            IList <int>     animateIndices       = ScanForAnimates(span);
            int             closestPronounIndex  = int.MinValue;
            int             closestAnimate       = int.MinValue;
            Pair <int, int> closestNameIndex     = new Pair <int, int>(0, int.MinValue);

            if (pronounIndices.Count > 0)
            {
                closestPronounIndex = pronounIndices[pronounIndices.Count - 1];
            }
            if (nameIndices.Count > 0)
            {
                closestNameIndex = nameIndices[nameIndices.Count - 1];
            }
            if (animateIndices.Count > 0)
            {
                closestAnimate = animateIndices[animateIndices.Count - 1];
            }
            Sieve.MentionData md = null;
            if (closestPronounIndex > closestNameIndex.second)
            {
                md = (closestAnimate > closestPronounIndex) ? new Sieve.MentionData(this, closestAnimate, closestAnimate, TokenRangeToString(closestAnimate), AnimateNoun) : new Sieve.MentionData(this, closestPronounIndex, closestPronounIndex, TokenRangeToString
                                                                                                                                                                                                       (closestPronounIndex), Pronoun);
            }
            else
            {
                if (closestPronounIndex < closestNameIndex.second)
                {
                    md = (closestAnimate > closestNameIndex.second) ? new Sieve.MentionData(this, closestAnimate, closestAnimate, TokenRangeToString(closestAnimate), AnimateNoun) : new Sieve.MentionData(this, closestNameIndex.first, closestNameIndex.second, TokenRangeToString
                                                                                                                                                                                                               (closestNameIndex), Name);
                }
            }
            return(md);
        }