1

我有一段文字,我想对它进行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);
}
4

0 回答 0