java.lang.NoClassDefFoundError: edu/stanford/nlp/parser/lexparser/LexicalizedParser
java.lang.NoClassDefFoundError: edu/stanford/nlp/parser/lexparser/LexicalizedParser
我正在使用 Stanford Parser API。我的系统规格如下:
OS: Win8
IDE: .IntelliJIdea14
JDK: 1.8
Stanford-Parser 3.5.2 版本
我在模块依赖项 (ClassPath) 中导入了 stanford-parser.jar 和 ejml-0.23.jar。
有一些解析器模型保存在名为 stanford-parser-3.5.2-models 的 jar 文件中。
斯坦福支持团队说:
"In recent distributions, the models are included in a jar file inside
the parser distribution. For example, in the 2012-11-12 distribution,
the models are included in stanford-parser-2.0.4-models.jar The
easiest way to access these models is to include this file in your
classpath. The parser will then be able to read the models from that
jar file. "
但是我无法导入 stanford-parser-3.5.2-models.jar 文件。所以我把它解压出来,把模型保存在D盘合适的地址,最后改成如下代码:
String parserModel = "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz";
LexicalizedParser lp = LexicalizedParser.loadModel(parserModel);
到
String parserModel = "D:\ MasterofScience\Tools\Stanford Dependenct Tree\models" +
"\lexparser\englishPCFG.ser.gz";
LexicalizedParser lp = LexicalizedParser.loadModel(parserModel);
但我给出了这些异常错误:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/parser/lexparser/LexicalizedParser
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:119)
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.parser.lexparser.LexicalizedParser
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
即使我不更改代码,我也会收到同样的异常!
我该怎么办?
您的类路径中缺少解析器 jar (stanford-parser.jar
)。实际上,您可以将解析器 jar 和模型 jar 添加到您的类路径中,然后程序应该可以运行。
我正在使用 Stanford Parser API。我的系统规格如下:
OS: Win8
IDE: .IntelliJIdea14
JDK: 1.8
Stanford-Parser 3.5.2 版本
我在模块依赖项 (ClassPath) 中导入了 stanford-parser.jar 和 ejml-0.23.jar。 有一些解析器模型保存在名为 stanford-parser-3.5.2-models 的 jar 文件中。
斯坦福支持团队说:
"In recent distributions, the models are included in a jar file inside the parser distribution. For example, in the 2012-11-12 distribution, the models are included in stanford-parser-2.0.4-models.jar The easiest way to access these models is to include this file in your classpath. The parser will then be able to read the models from that jar file. "
但是我无法导入 stanford-parser-3.5.2-models.jar 文件。所以我把它解压出来,把模型保存在D盘合适的地址,最后改成如下代码:
String parserModel = "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz";
LexicalizedParser lp = LexicalizedParser.loadModel(parserModel);
到
String parserModel = "D:\ MasterofScience\Tools\Stanford Dependenct Tree\models" +
"\lexparser\englishPCFG.ser.gz";
LexicalizedParser lp = LexicalizedParser.loadModel(parserModel);
但我给出了这些异常错误:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/parser/lexparser/LexicalizedParser
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:119)
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.parser.lexparser.LexicalizedParser
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
即使我不更改代码,我也会收到同样的异常! 我该怎么办?
您的类路径中缺少解析器 jar (stanford-parser.jar
)。实际上,您可以将解析器 jar 和模型 jar 添加到您的类路径中,然后程序应该可以运行。