Anaphora Resolution Using Stanford Coref

I have suggestions (text I) :

Tom is a smart boy. He knows a lot of things.

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

Tom is a smart boy. Tom knows a lot.

I wrote some code, but my coref object is always null .
In addition, I do not know what to do next to get the right 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);

, , II I.
PS: Stanford CoreNLP 1.3.0.

.

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

coref.

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

oldCorefFormat:

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

Source: https://habr.com/ru/post/1542580/


All Articles