Ejemplo n.º 1
0
        protected internal override List <string> GetFeatures(MentionContext mention, DiscourseEntity entity)
        {
            var features = base.GetFeatures(mention, entity);

            if (entity != null)
            {
                features.AddRange(GetPronounMatchFeatures(mention, entity));
                var contexts = GetContextFeatures(mention);
                var cec      = entity.LastExtent;
                if (PartsOfSpeech.IsPersOrPossPronoun(mention.HeadTokenTag) && PartsOfSpeech.IsPersOrPossPronoun(cec.HeadTokenTag))
                {
                    features.Add(mention.HeadTokenText + "," + cec.HeadTokenText);
                }
                else if (PartsOfSpeech.IsProperNoun(mention.HeadTokenText))
                {
                    for (int ci = 0, cl = contexts.Count; ci < cl; ci++)
                    {
                        features.Add(contexts[ci]);
                    }
                    features.Add(mention.NameType + "," + cec.HeadTokenText);
                }
                else
                {
                    var ccontexts = GetContextFeatures(cec);
                    for (int ci = 0, cl = ccontexts.Count; ci < cl; ci++)
                    {
                        features.Add(ccontexts[ci]);
                    }
                    features.Add(cec.NameType + "," + mention.HeadTokenText);
                }
            }
            return(features);
        }
Ejemplo n.º 2
0
        public override bool CanResolve(MentionContext mention)
        {
            string tag = mention.HeadTokenTag;
            bool   fpp = tag != null && PartsOfSpeech.IsPersonalOrPossessivePronoun(tag) && Linker.SpeechPronounPattern.IsMatch(mention.HeadTokenText);
            bool   pn  = tag != null && PartsOfSpeech.IsProperNoun(tag);

            return(fpp || pn);
        }
Ejemplo n.º 3
0
        public override bool CanResolve(MentionContext mention)
        {
            var tag = mention.HeadTokenTag;
            var fpp = tag != null && PartsOfSpeech.IsPersOrPossPronoun(tag) && Linker.SpeechPronounPattern.IsMatch(mention.HeadTokenText);
            var pn  = tag != null && PartsOfSpeech.IsProperNoun(tag);

            return(fpp || pn);
        }
Ejemplo n.º 4
0
        public override bool CanResolve(MentionContext mention)
        {
            Object[] mtokens = mention.Tokens;

            string firstTok = mention.FirstTokenText.ToLower();
            bool   rv       = mtokens.Length > 1 && !PartsOfSpeech.IsProperNoun(mention.HeadTokenTag) && IsDefiniteArticle(firstTok, mention.FirstTokenTag);

            return(rv);
        }
Ejemplo n.º 5
0
        //UPGRADE_NOTE: Access modifiers of method 'excluded' were changed to 'public'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1204'"
        protected internal override bool IsExcluded(MentionContext mention, DiscourseEntity entity)
        {
            if (base.IsExcluded(mention, entity))
            {
                return(true);
            }
            var cec = entity.LastExtent;

            if (!CanResolve(cec))
            {
                return(true);
            }
            if (PartsOfSpeech.IsProperNoun(mention.HeadTokenTag))
            {
                //mention is a propernoun
                if (PartsOfSpeech.IsProperNoun(cec.HeadTokenTag))
                {
                    return(true);                    // both NNP
                }
                else
                {
                    if (entity.MentionCount > 1)
                    {
                        return(true);
                    }
                    return(!CanResolve(cec));
                }
            }
            else if (PartsOfSpeech.IsPersOrPossPronoun(mention.HeadTokenTag))
            {
                // mention is a speech pronoun
                // cec can be either a speech pronoun or a propernoun
                if (PartsOfSpeech.IsProperNoun(cec.HeadTokenTag))
                {
                    //exclude antecedents not in the same sentence when they are not pronoun
                    return(mention.SentenceNumber - cec.SentenceNumber != 0);
                }
                else if (PartsOfSpeech.IsPersOrPossPronoun(cec.HeadTokenTag))
                {
                    return(false);
                }
                else
                {
                    Console.Error.WriteLine("Unexpected candidate exluded: " + cec.ToText());
                    return(true);
                }
            }
            else
            {
                Console.Error.WriteLine("Unexpected mention exluded: " + mention.ToText());
                return(true);
            }
        }
Ejemplo n.º 6
0
 private MentionContext getProperNounExtent(DiscourseEntity de)
 {
     foreach (MentionContext xec in de.Mentions)
     {
         //use first extent which is propername
         string xecHeadTag = xec.HeadTokenTag;
         if (PartsOfSpeech.IsProperNoun(xecHeadTag) || InitialCaps.IsMatch(xec.HeadTokenText))
         {
             return(xec);
         }
     }
     return(null);
 }
Ejemplo n.º 7
0
        protected internal override bool IsExcluded(MentionContext mention, DiscourseEntity entity)
        {
            if (base.IsExcluded(mention, entity))
            {
                return(true);
            }

            foreach (MentionContext xec in entity.Mentions)
            {
                if (PartsOfSpeech.IsProperNoun(xec.HeadTokenTag))
                {
                    // || initialCaps.matcher(xec.headToken.ToString()).find()) {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 8
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.º 9
0
 public override bool CanResolve(MentionContext mention)
 {
     return(PartsOfSpeech.IsProperNoun(mention.HeadTokenTag) || mention.HeadTokenTag.StartsWith(PartsOfSpeech.CardinalNumber));
 }
Ejemplo n.º 10
0
 private bool IsCommonNoun(Context nounPhrase)
 {
     return(!PartsOfSpeech.IsProperNoun(nounPhrase.HeadTokenTag) && PartsOfSpeech.IsNoun(nounPhrase.HeadTokenTag));
 }
Ejemplo n.º 11
0
 private bool IsName(Context nounPhrase)
 {
     return(PartsOfSpeech.IsProperNoun(nounPhrase.HeadTokenTag));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Returns a string for the specified mention with punctuation, honorifics, designators, and determiners removed.
        /// </summary>
        /// <param name="mention">
        /// The mention to be stripped.
        /// </param>
        /// <returns>
        /// a normalized string representation of the specified mention.
        /// </returns>
        protected internal virtual string StripNounPhrase(Mention.MentionContext mention)
        {
            int start = mention.NonDescriptorStart;             //start after descriptors

            Mention.IParse[] mentionTokens = mention.TokenParses;
            int end = mention.HeadTokenIndex + 1;

            if (start == end)
            {
                return(null);
            }
            //strip determiners
            if (mentionTokens[start].SyntacticType == PartsOfSpeech.Determiner)
            {
                start++;
            }
            if (start == end)
            {
                return(null);
            }
            //get to first NNP
            string type;

            for (int index = start; index < end; index++)
            {
                type = mentionTokens[start].SyntacticType;
                if (PartsOfSpeech.IsProperNoun(type))
                {
                    break;
                }
                start++;
            }
            if (start == end)
            {
                return(null);
            }
            if (start + 1 != end)
            {
                // don't do this on head words, to keep "U.S."
                //strip off honorifics in begining
                if (Linker.HonorificsPattern.IsMatch(mentionTokens[start].ToString()))
                {
                    start++;
                }
                if (start == end)
                {
                    return(null);
                }
                //strip off and honorifics on the end
                if (Linker.DesignatorsPattern.IsMatch(mentionTokens[mentionTokens.Length - 1].ToString()))
                {
                    end--;
                }
            }
            if (start == end)
            {
                return(null);
            }
            var strip = new StringBuilder();

            for (int i = start; i < end; i++)
            {
                strip.Append(mentionTokens[i].ToString()).Append(" ");
            }
            return(strip.ToString().Trim());
        }