Anaphora resolution using Stanford Coref

橙三吉。 提交于 2019-12-03 11:19:54

问题


I have sentences (Text I):

Tom is a smart boy. He know a lot of thing.

I want to change He in the second sentence to Tom, so final sentences will become (Text II):

Tom is a smart boy. Tom know a lot of thing.

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);

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.

Thanks.


回答1:


List<Pair<IntTuple, IntTuple>> coref = document.get(CorefGraphAnnotation.class);

This is an old coref output format.

You can change this line to

Map<Integer, CorefChain> graph = document.get(CorefChainAnnotation.class);

or you can use the oldCorefFormat option:

props.put("oldCorefFormat", "true");


来源:https://stackoverflow.com/questions/8768760/anaphora-resolution-using-stanford-coref

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!