使用CoreNLP的开源版本时无法加载OpenIE模型

时间:2016-05-12 23:52:35

标签: java serialization nlp stanford-nlp

我从this page下载了coreNLP的源代码和README文件中推荐的模型。我在eclipse中创建了一个新项目并试图通过它运行openie返回以下异常:

Exception in thread "main" edu.stanford.nlp.io.RuntimeIOException: Could not load clause splitter model at edu/stanford/nlp/models/naturalli/clauseSearcherModel.ser.gz
    at edu.stanford.nlp.naturalli.OpenIE.<init>(OpenIE.java:201)
    at edu.stanford.nlp.pipeline.AnnotatorImplementations.openie(AnnotatorImplementations.java:272)
    at edu.stanford.nlp.pipeline.AnnotatorFactories$20.create(AnnotatorFactories.java:654)
    at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:89)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:403)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:142)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:138)
    at edu.stanford.nlp.naturalli.demo.Demo.main(Demo.java:37)
Caused by: java.io.InvalidClassException: edu.stanford.nlp.naturalli.ClauseSplitterSearchProblem$8; local class incompatible: stream classdesc serialVersionUID = 4145523451314579506, local class serialVersionUID = -7360029270983346606
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:621)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1623)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
    at edu.stanford.nlp.io.IOUtils.readObjectFromURLOrClasspathOrFileSystem(IOUtils.java:325)
    at edu.stanford.nlp.naturalli.ClauseSplitter.load(ClauseSplitter.java:283)
    at edu.stanford.nlp.naturalli.OpenIE.<init>(OpenIE.java:196)
    ... 7 more

1 个答案:

答案 0 :(得分:1)

我已完成以下步骤:

  1. 克隆来自GitHub的回购:https://github.com/stanfordnlp/CoreNLP.git

  2. http://nlp.stanford.edu/software/stanford-corenlp-models-current.jar

  3. 下载最新型号的jar
  4. cd CoreNLP;蚂蚁

  5. 此时你应该在GitHub上构建最新版本的代码

  6. 将CLASSPATH设置为包含CoreNLP / classes,CoreNLP / lib和最新模型jar

  7. 运行此命令:java -Xmx4g edu.stanford.naturalli.OpenIE

  8. 它工作正常,所以我认为我们目前正在分发的内容没有任何问题。