我已经下载了Stanford corenlp Python包装器。我已经完成了link下的安装。
当我运行此代码时
>>> from stanford_corenlp_pywrapper import CoreNLP
>>> proc = CoreNLP("pos", corenlp_jars=["/home/sw/corenlp/stanford-corenlp-full-2015-04-20/*"])
我已经更改了jar位置,如下所示:
proc = CoreNLP("pos", corenlp_jars=["/media/pglab1-uni2/1EF20A75F20A5207/Anaconda2/stanford_corenlp_pywrapper-master/*"])
但是我收到如下错误:
INFO:CoreNLP_PyWrapper:mode given as 'pos' so setting annotators: tokenize, ssplit, pos, lemma
INFO:CoreNLP_PyWrapper:Starting java subprocess, and waiting for signal it's ready, with command: exec java -Xmx4g -XX:ParallelGCThreads=1 -cp '/media/pglab1-uni2/1EF20A75F20A5207/Anaconda2/stanford_corenlp_pywrapper-master/stanford_corenlp_pywrapper/lib/*:/media/pglab1-uni2/1EF20A75F20A5207/Anaconda2/stanford_corenlp_pywrapper-master/*' corenlp.SocketServer --outpipe /tmp/corenlp_pywrap_pipe_pypid=11181_time=1455081808.61 --configdict '{"annotators": "tokenize, ssplit, pos, lemma"}'
Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/pipeline/StanfordCoreNLP
at corenlp.JsonPipeline.initializeCorenlpPipeline(JsonPipeline.java:206)
at corenlp.SocketServer.main(SocketServer.java:102)
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.pipeline.StanfordCoreNLP
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more
请帮我解决错误
答案 0 :(得分:0)
两个原因可以是:
您没有包含被叫类或
你的罐子已损坏。
<强> 1。你没有jar 添加这些maven依赖项以获取与Standford CoreNLP相关的所有jar。
<properties>
<stanford.corenlp.version>3.9.1</stanford.corenlp.version>
</properties>
<dependencies>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>${stanford.corenlp.version}</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>${stanford.corenlp.version}</version>
<classifier>models</classifier>
</dependency>
</dependencies>
<强> 2。你的罐子已损坏
只需转到.m2文件夹并删除所有的Standford NLP罐子。再次从中央仓库下载jar。
3。如果你没有使用maven,那么检查你的jar是否已添加到classpath中?