本文介绍了使用Stanford Coref的回指解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有句子(文本I):
我想将第二句中的他更改为汤姆,因此最后一句话将变为(文本II):
I want to change He in the second sentence to Tom, so final sentences will become (Text II):
我写了一些代码,但是我的 coref 对象总是 null .
另外我不知道下一步该怎么做才能得到正确的结果.
I've wrote some code, but my coref object always null.
Besides I have no idea what to do next to get correct result.
String text = "Tom is a smart boy. He know a lot of thing.";
Annotation document = new Annotation(text);
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, parse, lemma, ner, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
List<Pair<IntTuple, IntTuple>> coref = document.get(CorefGraphAnnotation.class);
我想知道我做错了什么,接下来该怎么做才能从 Text I 中获得 Text II .
PS:我正在使用Stanford CoreNLP 1.3.0.
I want to know if I'm doing it wrong and what I should do next to get Text II from Text I.
PS: I'm using Stanford CoreNLP 1.3.0.
谢谢.
推荐答案
List<Pair<IntTuple, IntTuple>> coref = document.get(CorefGraphAnnotation.class);
这是旧的coref输出格式.
This is an old coref output format.
您可以将此行更改为
Map<Integer, CorefChain> graph = document.get(CorefChainAnnotation.class);
,或者您可以使用oldCorefFormat
选项:
or you can use the oldCorefFormat
option:
props.put("oldCorefFormat", "true");
这篇关于使用Stanford Coref的回指解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!