public virtual void Annotate(Annotation ann) { Document document; try { document = docMaker.MakeDocument(ann); } catch (Exception e) { throw new Exception("Error making document", e); } CorefUtils.CheckForInterrupt(); corefAlgorithm.RunCoref(document); if (removeSingletonClusters) { CorefUtils.RemoveSingletonClusters(document); } CorefUtils.CheckForInterrupt(); IDictionary <int, CorefChain> result = Generics.NewHashMap(); foreach (CorefCluster c in document.corefClusters.Values) { result[c.clusterID] = new CorefChain(c, document.positions); } ann.Set(typeof(CorefCoreAnnotations.CorefChainAnnotation), result); }
public void Process(int id, Document document) { writerGold.Print(CorefPrinter.PrintConllOutput(document, true)); writerBeforeCoref.Print(CorefPrinter.PrintConllOutput(document, false)); long time = Runtime.CurrentTimeMillis(); this._enclosing.corefAlgorithm.RunCoref(document); if (this._enclosing.verbose) { Redwood.Log(this.GetName(), "Coref took " + (Runtime.CurrentTimeMillis() - time) / 1000.0 + "s"); } CorefUtils.RemoveSingletonClusters(document); writerAfterCoref.Print(CorefPrinter.PrintConllOutput(document, false, true)); }
public static IDictionary <Pair <int, int>, bool> GetUnlabeledMentionPairs(Document document) { return(CorefUtils.GetMentionPairs(document).Stream().Collect(Collectors.ToMap(null, null))); }