如何使用Stanford core NLP在Java中执行共指消解?

如何使用Stanford core NLP在Java中执行共指消解?,java,xml-parsing,stanford-nlp,Java,Xml Parsing,Stanford Nlp,我有一段文字,我想对它执行coref解析,这样里面的所有代词都会被名词替换。以下是我使用的代码: Properties props = new Properties(); props.put("annotators", "tokenize, ssplit,pos,lemma,ner,parse,dcoref"); StanfordCoreNLP pi= new StanfordCoreNLP(props); String text = "Delhi is the capital city of

我有一段文字,我想对它执行coref解析,这样里面的所有代词都会被名词替换。以下是我使用的代码:

Properties props = new Properties();
props.put("annotators", "tokenize, ssplit,pos,lemma,ner,parse,dcoref");
StanfordCoreNLP pi= new StanfordCoreNLP(props);

String text = "Delhi is the capital city of India.It is the second most populous metropolis in India after Mumbai and the largest city in terms of area.";   
Annotation doc = new Annotation(text);
pi.annotate(doc);
Map<Integer, CorefChain> graph = doc.get(CorefChainAnnotation.class);
for (Map.Entry entry : graph.entrySet()) { 
    CorefChain c = (CorefChain) entry.getValue();
    CorefMention cm = c.getRepresentativeMention();
    System.out.println(c);
}

你有什么错误吗?看看这个示例代码:它对我和下载的包/stanfordNLP/StanfordCoreNlpDemo.javaant中的示例代码都很有用看到了吗