/// <summary>main entry of coreference system.</summary>
 /// <param name="document">Input document for coref format (Annotation and optional information)</param>
 /// <param name="output">For output of coref system (conll format and log. list size should be 4.)</param>
 /// <returns>Map of coref chain ID and corresponding chain</returns>
 /// <exception cref="System.Exception"/>
 public virtual IDictionary <int, CorefChain> Coref(Document document, StringBuilder[] output)
 {
     if (HybridCorefProperties.PrintMDLog(props))
     {
         Redwood.Log(HybridCorefPrinter.PrintMentionDetectionLog(document));
     }
     if (HybridCorefProperties.DoScore(props))
     {
         output[0] = (new StringBuilder()).Append(CorefPrinter.PrintConllOutput(document, true));
         // gold
         output[1] = (new StringBuilder()).Append(CorefPrinter.PrintConllOutput(document, false));
     }
     // before coref
     output[3] = new StringBuilder();
     // log from sieves
     foreach (Edu.Stanford.Nlp.Coref.Hybrid.Sieve.Sieve sieve in sieves)
     {
         CorefUtils.CheckForInterrupt();
         output[3].Append(sieve.ResolveMention(document, dictionaries, props));
     }
     // post processing
     if (HybridCorefProperties.DoPostProcessing(props))
     {
         PostProcessing(document);
     }
     if (HybridCorefProperties.DoScore(props))
     {
         output[2] = (new StringBuilder()).Append(CorefPrinter.PrintConllOutput(document, false, true));
     }
     // after coref
     return(MakeCorefOutput(document));
 }
        public static string PrintMentionDetectionLog(Document document)
        {
            StringBuilder    sbLog     = new StringBuilder();
            IList <ICoreMap> sentences = document.annotation.Get(typeof(CoreAnnotations.SentencesAnnotation));

            sbLog.Append("\nERROR START-----------------------------------------------------------------------\n");
            for (int i = 0; i < sentences.Count; i++)
            {
                sbLog.Append("\nSENT ").Append(i).Append(" GOLD   : ").Append(HybridCorefPrinter.SentenceStringWithMention(i, document, true, false)).Append("\n");
                sbLog.Append("SENT ").Append(i).Append(" PREDICT: ").Append(HybridCorefPrinter.SentenceStringWithMention(i, document, false, false)).Append("\n");
                //      for(CoreLabel cl : sentences.get(i).get(TokensAnnotation.class)) {
                //        sbLog.append(cl.word()).append("-").append(cl.get(UtteranceAnnotation.class)).append("-").append(cl.get(SpeakerAnnotation.class)).append(" ");
                //      }
                foreach (Mention p in document.predictedMentions[i])
                {
                    sbLog.Append("\n");
                    if (!p.hasTwin)
                    {
                        sbLog.Append("\tSPURIOUS");
                    }
                    sbLog.Append("\tmention: ").Append(p.SpanToString()).Append("\t\t\theadword: ").Append(p.headString).Append("\tPOS: ").Append(p.headWord.Tag()).Append("\tmentiontype: ").Append(p.mentionType).Append("\tnumber: ").Append(p.number).Append("\tgender: "
                                                                                                                                                                                                                                                                 ).Append(p.gender).Append("\tanimacy: ").Append(p.animacy).Append("\tperson: ").Append(p.person).Append("\tNE: ").Append(p.nerString);
                }
                sbLog.Append("\n");
                foreach (Mention g in document.goldMentions[i])
                {
                    if (!g.hasTwin)
                    {
                        sbLog.Append("\tmissed gold: ").Append(g.SpanToString()).Append("\tPOS: ").Append(g.headWord.Tag()).Append("\tmentiontype: ").Append(g.mentionType).Append("\theadword: ").Append(g.headString).Append("\tnumber: ").Append(g.number).Append("\tgender: "
                                                                                                                                                                                                                                                                     ).Append(g.gender).Append("\tanimacy: ").Append(g.animacy).Append("\tperson: ").Append(g.person).Append("\tNE: ").Append(g.nerString).Append("\n");
                        if (g.sentenceWords != null)
                        {
                            if (g.sentenceWords.Count > g.endIndex)
                            {
                                sbLog.Append("\tnextword: ").Append(g.sentenceWords[g.endIndex]).Append("\t").Append(g.sentenceWords[g.endIndex].Tag()).Append("\n");
                            }
                        }
                        if (g.contextParseTree != null)
                        {
                            sbLog.Append(g.contextParseTree.PennString()).Append("\n\n");
                        }
                        else
                        {
                            sbLog.Append("\n\n");
                        }
                    }
                }
                if (sentences[i].Get(typeof(TreeCoreAnnotations.TreeAnnotation)) != null)
                {
                    sbLog.Append("\n\tparse: \n").Append(sentences[i].Get(typeof(TreeCoreAnnotations.TreeAnnotation)).PennString());
                }
                sbLog.Append("\n\tcollapsedDependency: \n").Append(sentences[i].Get(typeof(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation)));
            }
            sbLog.Append("ERROR END -----------------------------------------------------------------------\n");
            return(sbLog.ToString());
        }