我正在使用Stanford Parser API。我的系統規格如下所列:java.lang.NoClassDefFoundError:edu/stanford/nlp/parser/lexparser/LexicalizedParser
操作系統:Win8的
IDE:.IntelliJIdea14
JDK 1.8
斯坦福分析器3.5.2版本
我已經進口斯坦福解析器.jar和ejml-0.23.jar在模塊依賴關係(ClassPath)中。 有一些解析器模型保存在名爲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. "
但我無法導入斯坦福解析器-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
即使我不改變代碼,我收到相同的異常! 我該怎麼辦?
程序正在尋找一個不存在的文件夾中的類:'edu/stanford/nlp/parser/lexparser/LexicalizedParser' – Arc676