예제 #1
0
        /// <summary>Main method of mention detection.</summary>
        /// <remarks>
        /// Main method of mention detection.
        /// Extract all NP, PRP or NE, and filter out by manually written patterns.
        /// </remarks>
        public override IList <IList <Mention> > FindMentions(Annotation doc, Dictionaries dict, Properties props)
        {
            IList <IList <Mention> >       predictedMentions  = new List <IList <Mention> >();
            ICollection <string>           neStrings          = Generics.NewHashSet();
            IList <ICollection <IntPair> > mentionSpanSetList = Generics.NewArrayList();
            IList <ICoreMap> sentences = doc.Get(typeof(CoreAnnotations.SentencesAnnotation));

            foreach (ICoreMap s in sentences)
            {
                IList <Mention> mentions = new List <Mention>();
                predictedMentions.Add(mentions);
                ICollection <IntPair> mentionSpanSet     = Generics.NewHashSet();
                ICollection <IntPair> namedEntitySpanSet = Generics.NewHashSet();
                ExtractPremarkedEntityMentions(s, mentions, mentionSpanSet, namedEntitySpanSet);
                HybridCorefMentionFinder.ExtractNamedEntityMentions(s, mentions, mentionSpanSet, namedEntitySpanSet);
                ExtractNPorPRPFromDependency(s, mentions, mentionSpanSet, namedEntitySpanSet);
                AddNamedEntityStrings(s, neStrings, namedEntitySpanSet);
                mentionSpanSetList.Add(mentionSpanSet);
            }
            //    extractNamedEntityModifiers(sentences, mentionSpanSetList, predictedMentions, neStrings);
            for (int i = 0; i < sentences.Count; i++)
            {
                FindHead(sentences[i], predictedMentions[i]);
            }
            // mention selection based on document-wise info
            RemoveSpuriousMentions(doc, predictedMentions, dict, CorefProperties.RemoveNestedMentions(props), lang);
            // if this is for MD training, skip classification
            if (!CorefProperties.IsMentionDetectionTraining(props))
            {
                mdClassifier.ClassifyMentions(predictedMentions, dict, props);
            }
            return(predictedMentions);
        }
예제 #2
0
 /// <exception cref="System.TypeLoadException"/>
 /// <exception cref="System.IO.IOException"/>
 public HybridCorefMentionFinder(IHeadFinder headFinder, Properties props)
 {
     this.headFinder = headFinder;
     this.lang       = CorefProperties.GetLanguage(props);
     mdClassifier    = (CorefProperties.IsMentionDetectionTraining(props)) ? null : IOUtils.ReadObjectFromURLOrClasspathOrFileSystem(CorefProperties.GetMentionDetectionModel(props));
 }