Ejemplo n.º 1
0
 public override bool CanResolve(MentionContext context)
 {
     if (PartsOfSpeech.IsNoun(context.HeadTokenTag))
     {
         return(context.PreviousToken != null && predicativePattern.IsMatch(context.PreviousToken.ToString()));
     }
     return(false);
 }
 private static string GetHeadTag(Tree t)
 {
     if (PartsOfSpeech.IsNoun(t.Value()))
     {
         return(Noun);
     }
     else if (PartsOfSpeech.IsAdjective(t.Value()))
     {
         return(Adjective);
     }
     else
     {
         return(Noun);
     }
 }
Ejemplo n.º 3
0
        private void CollectCoordinatedNounPhraseMentions(IParse nounPhrase, List <Mention> entities)
        {
            List <IParse> nounPhraseTokens         = nounPhrase.Tokens;
            bool          inCoordinatedNounPhrase  = false;
            int           lastNounPhraseTokenIndex = mHeadFinder.GetHeadIndex(nounPhrase);

            for (int tokenIndex = lastNounPhraseTokenIndex - 1; tokenIndex >= 0; tokenIndex--)
            {
                IParse token     = nounPhraseTokens[tokenIndex];
                string tokenText = token.ToString();
                if (tokenText == "and" || tokenText == "or")
                {
                    if (lastNounPhraseTokenIndex != tokenIndex)
                    {
                        if (tokenIndex - 1 >= 0 && PartsOfSpeech.IsNoun(nounPhraseTokens[tokenIndex - 1].SyntacticType))
                        {
                            var nounPhraseSpan       = new Util.Span((nounPhraseTokens[tokenIndex + 1]).Span.Start, (nounPhraseTokens[lastNounPhraseTokenIndex]).Span.End);
                            var nounPhraseSpanExtent = new Mention(nounPhraseSpan, nounPhraseSpan, token.EntityId, null, "CNP");
                            entities.Add(nounPhraseSpanExtent);
                            inCoordinatedNounPhrase = true;
                        }
                        else
                        {
                            break;
                        }
                    }
                    lastNounPhraseTokenIndex = tokenIndex - 1;
                }
                else if (inCoordinatedNounPhrase && tokenText == PartsOfSpeech.Comma)
                {
                    if (lastNounPhraseTokenIndex != tokenIndex)
                    {
                        var nounPhraseSpan       = new Util.Span((nounPhraseTokens[tokenIndex + 1]).Span.Start, (nounPhraseTokens[lastNounPhraseTokenIndex]).Span.End);
                        var nounPhraseSpanExtent = new Mention(nounPhraseSpan, nounPhraseSpan, token.EntityId, null, "CNP");
                        entities.Add(nounPhraseSpanExtent);
                    }
                    lastNounPhraseTokenIndex = tokenIndex - 1;
                }
                else if (inCoordinatedNounPhrase && tokenIndex == 0 && lastNounPhraseTokenIndex >= 0)
                {
                    var nounPhraseSpan       = new Util.Span((nounPhraseTokens[tokenIndex]).Span.Start, (nounPhraseTokens[lastNounPhraseTokenIndex]).Span.End);
                    var nounPhraseSpanExtent = new Mention(nounPhraseSpan, nounPhraseSpan, token.EntityId, null, "CNP");
                    entities.Add(nounPhraseSpanExtent);
                }
            }
        }
Ejemplo n.º 4
0
        private void Initialize(Mention.IHeadFinder headFinder)
        {
            Mention.IParse        head      = headFinder.GetLastHead(Parse);
            List <Mention.IParse> tokenList = head.Tokens;

            this.HeadTokenIndex = headFinder.GetHeadIndex(head);
            Mention.IParse headToken = headFinder.GetHeadToken(head);
            _tokens            = tokenList.ToArray();
            this.HeadTokenTag  = headToken.SyntacticType;
            this.HeadTokenText = headToken.ToString();
            if (PartsOfSpeech.IsNoun(this.HeadTokenTag) && !PartsOfSpeech.IsProperNoun(this.HeadTokenTag))
            {
                this.Synsets = GetSynsetSet(this);
            }
            else
            {
                this.Synsets = new Util.HashSet <string>();
            }
        }
Ejemplo n.º 5
0
 private bool IsCommonNoun(Context nounPhrase)
 {
     return(!PartsOfSpeech.IsProperNoun(nounPhrase.HeadTokenTag) && PartsOfSpeech.IsNoun(nounPhrase.HeadTokenTag));
 }