我正在使用StanfordCoreNLP库(stanford-corenlp.jar),并且在执行下面的代码行时出错。
protected StanfordCoreNLP pipeline;
public LemmatizerHelper() {
Properties props;
props = new Properties();
props.put("annotators", "tokenize,ssplit,pos,lemma,ner,parse,dcoref");
this.pipeline = new StanfordCoreNLP(props); // Error occurs from this line
}
这是我得到的错误。
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Loading POS Model [edu/stanford/nlp/models/pos-tagger/wsj3t0-18-left3words/left3words-distsim-wsj-0-18.tagger] ... Loading default properties from trained tagger edu/stanford/nlp/models/pos-tagger/wsj3t0-18-left3words/left3words-distsim-wsj-0-18.tagger
Error: No such trained tagger config file found.
java.io.FileNotFoundException: edu\stanford\nlp\models\pos-tagger\wsj3t0-18-left3words\left3words-distsim-wsj-0-18.tagger (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at edu.stanford.nlp.tagger.maxent.TaggerConfig.getTaggerDataInputStream(TaggerConfig.java:737)
at edu.stanford.nlp.tagger.maxent.TaggerConfig.<init>(TaggerConfig.java:185)
at edu.stanford.nlp.tagger.maxent.TaggerConfig.<init>(TaggerConfig.java:130)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:240)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:69)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:43)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:496)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:489)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:62)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:325)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:374)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:364)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:356)
at irproject.LemmatizerHelper.<init>(LemmatizerHelper.java:25)
at irproject.PreProcessingHelper.Lemmatization(PreProcessingHelper.java:59)
at irproject.IRProject.main(IRProject.java:30)
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: edu\stanford\nlp\models\pos-tagger\wsj3t0-18-left3words\left3words-distsim-wsj-0-18.tagger (The system cannot find the path specified)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:498)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:489)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:62)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:325)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:374)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:364)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:356)
at irproject.LemmatizerHelper.<init>(LemmatizerHelper.java:25)
at irproject.PreProcessingHelper.Lemmatization(PreProcessingHelper.java:59)
at irproject.IRProject.main(IRProject.java:30)
Caused by: java.io.FileNotFoundException: edu\stanford\nlp\models\pos-tagger\wsj3t0-18-left3words\left3words-distsim-wsj-0-18.tagger (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at edu.stanford.nlp.tagger.maxent.TaggerConfig.getTaggerDataInputStream(TaggerConfig.java:737)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:667)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:280)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:240)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:69)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:43)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:496)
... 9 more
这是我下载jar文件的地方 http://www.java2s.com/Code/Jar/s/Downloadstanfordcorenlpjar.htm
我正在使用Netbeans IDE 8.1
答案 0 :(得分:1)
你应该从这个网站获得Stanford CoreNLP 3.7.0:
http://stanfordnlp.github.io/CoreNLP/download.html
确保CLASSPATH中已下载文件夹中的所有jar文件。在您的CLASSPATH中没有stanford-corenlp-3.7.0-models.jar会导致您看到的错误类型。