0
我面對這個問題:StanfordCoreNLP對象創建錯誤
Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Error while loading a tagger model (probably missing model file)
Caused by: java.io.InvalidClassException: edu.stanford.nlp.tagger.maxent.ExtractorDistsim; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = 2
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:616)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1630)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1714)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2018)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1942)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1808)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readExtractors(MaxentTagger.java:622)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:868)
... 23 more
在代碼行
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref, sentiment");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
注:我已經把斯坦福核心NLP最新的jar文件,但它沒有工作,甚至嘗試明確添加stanford nlp pos tagger jar文件,但它沒有工作,甚至嘗試添加模型jar文件,但沒有工作。
請幫忙。
你能發佈你用來運行程序的確切命令嗎?此錯誤是由模型jar不在您的類路徑中引起的。 –
@GaborAngeli我沒有在命令行上運行它,我正在使用IntelliJ Idea。我添加了jar文件 - > 1. stanford-corenlp-3.7.0.jar 2. stanford-corenlp-3.7.0-models.jar –
@GaborAngeli我編輯了異常的問題堆棧跟蹤請檢查... ... –