java - Getting corefrences with Standard corenlp package -


i'm trying coreferences in text. i'm new corenlp package. tried code below, doesn't work, i'm open other methods well.

/*  * change template, choose tools | templates  * , open template in editor.  */  package corenlp; import edu.stanford.nlp.ling.coreannotations.collapsedccprocesseddependenciesannotation; import edu.stanford.nlp.ling.coreannotations.corefgraphannotation; import edu.stanford.nlp.ling.coreannotations.namedentitytagannotation; import edu.stanford.nlp.ling.coreannotations.partofspeechannotation; import edu.stanford.nlp.ling.coreannotations.sentencesannotation; import edu.stanford.nlp.ling.coreannotations.textannotation; import edu.stanford.nlp.ling.coreannotations.tokensannotation; import edu.stanford.nlp.ling.coreannotations.treeannotation; import edu.stanford.nlp.ling.corelabel; import edu.stanford.nlp.pipeline.*; import edu.stanford.nlp.trees.tree; import edu.stanford.nlp.trees.semgraph.semanticgraph; import edu.stanford.nlp.util.coremap; import edu.stanford.nlp.util.inttuple; import edu.stanford.nlp.util.pair; import edu.stanford.nlp.util.timing; import java.io.file; import java.io.fileinputstream; import java.io.ioexception; import java.util.arraylist; import java.util.list;  import java.util.properties; /**  *  * @author karthi  */ public class main {           // creates stanfordcorenlp object, pos tagging, lemmatization, ner, parsing, , coreference resolution     properties props = new properties();     fileinputstream in = new fileinputstream("main.properties");      props.load(in);     in.close();     stanfordcorenlp pipeline = new stanfordcorenlp(props);      // read text in text variable     string text = "the doctor can consult other doctors patient. if case, name of doctor , names of consultants have maintained. otherwise, name of doctor kept. "; // add text here!      // create empty annotation given text     annotation document = new annotation(text);      // run annotators on text     pipeline.annotate(document);     system.out.println(document);     // these sentences in document     // coremap map uses class objects keys , has values custom types     list<coremap> sentences = (list<coremap>) document.get(sentencesannotation.class);     system.out.println(sentences);     for(coremap sentence: sentences) {       // traversing words in current sentence       // corelabel coremap additional token-specific methods       (corelabel token: sentence.get(tokensannotation.class)) {         // text of token         string word = token.get(textannotation.class);         // pos tag of token         string pos = token.get(partofspeechannotation.class);         // ner label of token         string ne = token.get(namedentitytagannotation.class);       }        // parse tree of current sentence       tree tree = sentence.get(treeannotation.class); system.out.println(tree);       // stanford dependency graph of current sentence       semanticgraph dependencies = sentence.get(collapsedccprocesseddependenciesannotation.class);       system.out.println(dependencies);     }      // coreference link graph     // each link stores arc in graph; first element in pair source, second target     // each node stored <sentence id, token id>. both offsets start @ 1!     list<pair<inttuple, inttuple>> graph = document.get(corefgraphannotation.class);     system.out.println(graph);      }  } 

this error get:

loading pos model [// pos model] ... loading default properties trained tagger // pos model error: no such trained tagger config file found. java.io.filenotfoundexception: \\ pos model (the specified path invalid)         @ java.io.fileinputstream.open(native method)         @ java.io.fileinputstream.<init>(fileinputstream.java:106)         @ java.io.fileinputstream.<init>(fileinputstream.java:66)         @ edu.stanford.nlp.tagger.maxent.taggerconfig.gettaggerdatainputstream(taggerconfig.java:741)         @ edu.stanford.nlp.tagger.maxent.taggerconfig.<init>(taggerconfig.java:178)         @ edu.stanford.nlp.tagger.maxent.maxenttagger.<init>(maxenttagger.java:228)         @ edu.stanford.nlp.pipeline.postaggerannotator.loadmodel(postaggerannotator.java:57)         @ edu.stanford.nlp.pipeline.postaggerannotator.<init>(postaggerannotator.java:44)         @ edu.stanford.nlp.pipeline.stanfordcorenlp$4.create(stanfordcorenlp.java:441)         @ edu.stanford.nlp.pipeline.stanfordcorenlp$4.create(stanfordcorenlp.java:434)         @ edu.stanford.nlp.pipeline.annotatorpool.get(annotatorpool.java:62)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.construct(stanfordcorenlp.java:309)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.<init>(stanfordcorenlp.java:347)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.<init>(stanfordcorenlp.java:337)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.<init>(stanfordcorenlp.java:329)         @ corenlp.main.main(main.java:66) exception in thread "main" java.lang.runtimeexception: java.io.filenotfoundexception: \\ pos model (the specified path invalid)         @ edu.stanford.nlp.pipeline.stanfordcorenlp$4.create(stanfordcorenlp.java:443)         @ edu.stanford.nlp.pipeline.stanfordcorenlp$4.create(stanfordcorenlp.java:434)         @ edu.stanford.nlp.pipeline.annotatorpool.get(annotatorpool.java:62)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.construct(stanfordcorenlp.java:309)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.<init>(stanfordcorenlp.java:347)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.<init>(stanfordcorenlp.java:337)         @ edu.stanford.nlp.pipeline.stanfordcorenlp.<init>(stanfordcorenlp.java:329)         @ corenlp.main.main(main.java:66) caused by: java.io.filenotfoundexception: \\ pos model (the specified path invalid)         @ java.io.fileinputstream.open(native method)         @ java.io.fileinputstream.<init>(fileinputstream.java:106)         @ java.io.fileinputstream.<init>(fileinputstream.java:66)         @ edu.stanford.nlp.tagger.maxent.taggerconfig.gettaggerdatainputstream(taggerconfig.java:741)         @ edu.stanford.nlp.tagger.maxent.maxenttagger.readmodelandinit(maxenttagger.java:643)         @ edu.stanford.nlp.tagger.maxent.maxenttagger.<init>(maxenttagger.java:268)         @ edu.stanford.nlp.tagger.maxent.maxenttagger.<init>(maxenttagger.java:228)         @ edu.stanford.nlp.pipeline.postaggerannotator.loadmodel(postaggerannotator.java:57)         @ edu.stanford.nlp.pipeline.postaggerannotator.<init>(postaggerannotator.java:44)         @ edu.stanford.nlp.pipeline.stanfordcorenlp$4.create(stanfordcorenlp.java:441)         ... 7 more java result: 1 

this error means program not finding data models needs run. need on classpath. if you're in distribution directory, can command like:

java -cp stanford-corenlp-2010-11-12.jar:stanford-corenlp-models-2010-11-06.jar:xom.jar:jgrapht.jar -xmx3g edu.stanford.nlp.pipeline.stanfordcorenlp -annotators tokenize,ssplit,pos,lemma,ner,parse,dcoref -file input.txt 

the second jar contains models. if you're using windows, replace colons above semicolons.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -