private Mention[] CollectMentions(List <IParse> nounPhrases, Dictionary <IParse, IParse> headMap)
        {
            List <Mention> mentions = new List <Mention>(nounPhrases.Count);

            Util.Set <IParse> recentMentions = new Util.HashSet <IParse>();
            //System.err.println("AbtractMentionFinder.collectMentions: "+headMap);
            for (int nounPhraseIndex = 0; nounPhraseIndex < nounPhrases.Count; nounPhraseIndex++)
            {
                IParse nounPhrase = nounPhrases[nounPhraseIndex];
                //System.err.println("AbstractMentionFinder: collectMentions: np[" + npi + "]=" + np + " head=" + headMap.get(np));
                if (!IsHeadOfExistingMention(nounPhrase, headMap, recentMentions))
                {
                    ClearMentions(recentMentions, nounPhrase);
                    if (!IsPartOfName(nounPhrase))
                    {
                        IParse  head   = mHeadFinder.GetLastHead(nounPhrase);
                        Mention extent = new Mention(nounPhrase.Span, head.Span, head.EntityId, nounPhrase, null);
                        //System.err.println("adding "+np+" with head "+head);
                        mentions.Add(extent);
                        recentMentions.Add(nounPhrase);
                        // determine name-entity type
                        string entityType = GetEntityType(mHeadFinder.GetHeadToken(head));
                        if (entityType != null)
                        {
                            extent.NameType = entityType;
                        }
                    }
                    else
                    {
                        //System.err.println("AbstractMentionFinder.collectMentions excluding np as part of name. np=" + np);
                    }
                }
                else
                {
                    //System.err.println("AbstractMentionFinder.collectMentions excluding np as head of previous mention. np=" + np);
                }
                if (IsBasalNounPhrase(nounPhrase))
                {
                    if (mPrenominalNamedEntitiesCollection)
                    {
                        CollectPrenominalNamedEntities(nounPhrase, mentions);
                    }
                    if (mCoordinatedNounPhrasesCollection)
                    {
                        CollectCoordinatedNounPhraseMentions(nounPhrase, mentions);
                    }
                    CollectPossessivePronouns(nounPhrase, mentions);
                }
                else
                {
                    // Could use to get NP -> tokens CON structures for basal nps including NP -> NAC tokens
                    //collectComplexNounPhrases(np,mentions);
                }
            }

            mentions.Sort();
            RemoveDuplicates(mentions);
            return(mentions.ToArray());
        }
Beispiel #2
0
        private Mention[] CollectMentions(List <IParse> nounPhrases, Dictionary <IParse, IParse> headMap)
        {
            var mentions = new List <Mention>(nounPhrases.Count);

            Util.Set <IParse> recentMentions = new Util.HashSet <IParse>();
            for (int nounPhraseIndex = 0; nounPhraseIndex < nounPhrases.Count; nounPhraseIndex++)
            {
                IParse nounPhrase = nounPhrases[nounPhraseIndex];
                if (!IsHeadOfExistingMention(nounPhrase, headMap, recentMentions))
                {
                    ClearMentions(recentMentions, nounPhrase);
                    if (!IsPartOfName(nounPhrase))
                    {
                        IParse head   = mHeadFinder.GetLastHead(nounPhrase);
                        var    extent = new Mention(nounPhrase.Span, head.Span, head.EntityId, nounPhrase, null);
                        mentions.Add(extent);
                        recentMentions.Add(nounPhrase);
                        // determine name-entity type
                        string entityType = GetEntityType(mHeadFinder.GetHeadToken(head));
                        if (entityType != null)
                        {
                            extent.NameType = entityType;
                        }
                    }
                }
                if (IsBasalNounPhrase(nounPhrase))
                {
                    if (mPrenominalNamedEntitiesCollection)
                    {
                        CollectPrenominalNamedEntities(nounPhrase, mentions);
                    }
                    if (mCoordinatedNounPhrasesCollection)
                    {
                        CollectCoordinatedNounPhraseMentions(nounPhrase, mentions);
                    }
                    CollectPossessivePronouns(nounPhrase, mentions);
                }
                else
                {
                    // Could use to get NP -> tokens CON structures for basal nps including NP -> NAC tokens
                    //collectComplexNounPhrases(np,mentions);
                }
            }

            mentions.Sort();
            RemoveDuplicates(mentions);
            return(mentions.ToArray());
        }
        public MentionContext(Util.Span span, Util.Span headSpan, int entityId, IParse parse, string extentType, string nameType, int mentionIndex, int mentionsInSentence, int mentionIndexInDocument, int sentenceIndex, IHeadFinder headFinder) : base(span, headSpan, entityId, parse, extentType, nameType, headFinder)
        {
            mNounLocation    = mentionIndex;
            mMaxNounLocation = mentionsInSentence;
            mNounNumber      = mentionIndexInDocument;
            mSentenceNumber  = sentenceIndex;
            mIndexSpan       = parse.Span;
            mPreviousToken   = parse.PreviousToken;
            mNextToken       = parse.NextToken;
            mHead            = headFinder.GetLastHead(parse);
            List <IParse> headTokens = mHead.Tokens;

            Tokens          = headTokens.ToArray();
            mBasalNextToken = mHead.NextToken;
            //System.err.println("MentionContext.init: "+ent+" "+ent.getEntityId()+" head="+head);
            //mNonDescriptorStart = 0;
            InitializeHeads(headFinder.GetHeadIndex(mHead));
            mGender            = Similarity.GenderEnum.Unknown;
            mGenderProbability = 0d;
            mNumber            = Similarity.NumberEnum.Unknown;
            mNumberProbability = 0d;
        }
Beispiel #4
0
        public MentionContext(Util.Span span, Util.Span headSpan, int entityId, IParse parse, string extentType, string nameType,
                              int mentionIndex, int mentionsInSentence, int mentionIndexInDocument, int sentenceIndex, IHeadFinder headFinder) :
            base(span, headSpan, entityId, parse, extentType, nameType, headFinder)
        {
            NounPhraseSentenceIndex    = mentionIndex;
            MaxNounPhraseSentenceIndex = mentionsInSentence;
            NounPhraseDocumentIndex    = mentionIndexInDocument;
            SentenceNumber             = sentenceIndex;
            IndexSpan     = parse.Span;
            PreviousToken = parse.PreviousToken;
            NextToken     = parse.NextToken;
            Head          = headFinder.GetLastHead(parse);
            List <IParse> headTokens = Head.Tokens;

            Tokens         = headTokens.ToArray();
            NextTokenBasal = Head.NextToken;
            //mNonDescriptorStart = 0;
            InitializeHeads(headFinder.GetHeadIndex(Head));
            mGender           = Similarity.GenderEnum.Unknown;
            GenderProbability = 0d;
            _number           = Similarity.NumberEnum.Unknown;
            NumberProbability = 0d;
        }
 public MentionContext(Util.Span span, Util.Span headSpan, int entityId, IParse parse, string extentType, string nameType, 
     int mentionIndex, int mentionsInSentence, int mentionIndexInDocument, int sentenceIndex, IHeadFinder headFinder)
     : base(span, headSpan, entityId, parse, extentType, nameType, headFinder)
 {
     NounPhraseSentenceIndex = mentionIndex;
     MaxNounPhraseSentenceIndex = mentionsInSentence;
     NounPhraseDocumentIndex = mentionIndexInDocument;
     SentenceNumber = sentenceIndex;
     IndexSpan = parse.Span;
     PreviousToken = parse.PreviousToken;
     NextToken = parse.NextToken;
     Head = headFinder.GetLastHead(parse);
     List<IParse> headTokens = Head.Tokens;
     Tokens = headTokens.ToArray();
     NextTokenBasal = Head.NextToken;
     //System.err.println("MentionContext.init: "+ent+" "+ent.getEntityId()+" head="+head);
     //mNonDescriptorStart = 0;
     InitializeHeads(headFinder.GetHeadIndex(Head));
     mGender = Similarity.GenderEnum.Unknown;
     GenderProbability = 0d;
     _number = Similarity.NumberEnum.Unknown;
     NumberProbability = 0d;
 }