我有一段文字,我想在其上执行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);
}