how to get Coreference Resolution annotation in stanford core nlp toolkit? -
i'm trying use stanford corenlp toolkit annotate text. tried use code provided here : http://stanfordnlp.github.io/corenlp/ , works well. problem when want use co-reference resolution tool embedded in corenlp toolkit. not work. used code published stanford nlp group. code here below:
public class corefexample { public static void main(string[] args) throws exception { annotation document = new annotation("barack obama born in hawaii. president. obama elected in 2008."); properties props = new properties(); props.setproperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,mention,coref"); stanfordcorenlp pipeline = new stanfordcorenlp(props); pipeline.annotate(document); system.out.println("---"); system.out.println("coref chains"); (corefchain cc : document.get(corefcoreannotations.corefchainannotation.class).values()) { system.out.println("\t"+cc); } (coremap sentence : document.get(coreannotations.sentencesannotation.class)) { system.out.println("---"); system.out.println("mentions"); (mention m : sentence.get(corefcoreannotations.corefmentionsannotation.class)) { system.out.println("\t"+m); } } } }
but when want run these codes, got null,this line : "sentence.get(corefcoreannotations.corefmentionsannotation.class)" return null, while sure toolkit has annotaed corefrence mentions. mixed up. solution? how can receive coref annottaion in java code?
if run sample code on coref page latest stanford-corenlp-3.6.0.jar runs completion, not seeing null issue talking about.
make sure use latest jar available on website, version 3.6.0
update:
if cut , paste code on page:
http://stanfordnlp.github.io/corenlp/coref.html
and put file called corefexample.java do:
javac -cp "stanford-corenlp-full-2015-12-09/*" corefexample.java java -cp "stanford-corenlp-full-2015-12-09/*:." corefexample
you should see mentions printed out.
we've updated distribution, make sure you've downloaded recently.
if you're still having problems have figure out different described , set up. cut , paste code , ran described above , see mentions printed out (i added sentence no mentions sample text) , list mentions (or empty list). shouldn't getting null if you're using exact code latest jar.
it helpful know how you're running code can see difference is.
Comments
Post a Comment