Beispiel #1
0
        private void CollectPossessivePronouns(IParse nounPhrase, List <Mention> entities)
        {
            //TODO: Look at how training is done and examine whether this is needed or can be accomidated in a different way.

            /*
             * List snps = np.getSubNounPhrases();
             * if (snps.size() != 0) {
             * for (int si = 0, sl = snps.size(); si < sl; si++) {
             * Parse snp = (Parse) snps.get(si);
             * Extent ppExtent = new Extent(snp.getSpan(), snp.getSpan(), snp.getEntityId(), null,Linker.PRONOUN_MODIFIER);
             * entities.add(ppExtent);
             * }
             * }
             * else {
             */
            List <IParse> nounPhraseTokens = nounPhrase.Tokens;
            IParse        headToken        = mHeadFinder.GetHeadToken(nounPhrase);

            for (int tokenIndex = nounPhraseTokens.Count - 2; tokenIndex >= 0; tokenIndex--)
            {
                IParse token = nounPhraseTokens[tokenIndex];
                if (token == headToken)
                {
                    continue;
                }
                if (PartsOfSpeech.IsPersOrPossPronoun(token.SyntacticType) && IsHandledPronoun(token.ToString()))
                {
                    var possessivePronounExtent = new Mention(token.Span, token.Span, token.EntityId, null, Linker.PronounModifier);
                    entities.Add(possessivePronounExtent);
                    break;
                }
            }
            //}
        }
        private void CollectPossessivePronouns(IParse nounPhrase, List <Mention> entities)
        {
            //TODO: Look at how training is done and examine whether this is needed or can be accomidated in a different way.

            /*
             * List snps = np.getSubNounPhrases();
             * if (snps.size() != 0) {
             * //System.err.println("AbstractMentionFinder: Found existing snps");
             * for (int si = 0, sl = snps.size(); si < sl; si++) {
             * Parse snp = (Parse) snps.get(si);
             * Extent ppExtent = new Extent(snp.getSpan(), snp.getSpan(), snp.getEntityId(), null,Linker.PRONOUN_MODIFIER);
             * entities.add(ppExtent);
             * }
             * }
             * else {
             */
            //System.err.println("AbstractEntityFinder.collectPossesivePronouns: "+np);
            List <IParse> nounPhraseTokens = nounPhrase.Tokens;
            IParse        headToken        = mHeadFinder.GetHeadToken(nounPhrase);

            for (int tokenIndex = nounPhraseTokens.Count - 2; tokenIndex >= 0; tokenIndex--)
            {
                IParse token = nounPhraseTokens[tokenIndex];
                if (token == headToken)
                {
                    continue;
                }
                if (token.SyntacticType.StartsWith("PRP") && IsHandledPronoun(token.ToString()))
                {
                    Mention possessivePronounExtent = new Mention(token.Span, token.Span, token.EntityId, null, OpenNLP.Tools.Coreference.Linker.PronounModifier);
                    //System.err.println("AbstractEntityFinder.collectPossesivePronouns: adding possesive pronoun: "+tok+" "+tok.getEntityId());
                    entities.Add(possessivePronounExtent);
                    //System.err.println("AbstractMentionFinder: adding pos-pro: "+ppExtent);
                    break;
                }
            }
            //}
        }