我已按照以下网址设置了stanford CoreNLP。
我的$CLASSPATH
如下。
https://stanfordnlp.github.io/CoreNLP/download.html
$ echo $CLASSPATH | sed 's/:/\n/g'
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/javax.json-api-1.0-sources.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/ejml-0.23.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/slf4j-api.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/stanford-corenlp-3.9.0-javadoc.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/stanford-corenlp-3.9.0-sources.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/protobuf.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/stanford-corenlp-3.9.0-models.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/joda-time.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/joda-time-2.9-sources.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/xom-1.2.10-src.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/xom.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/javax.json.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/stanford-corenlp-3.9.0.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/jollyday.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/slf4j-simple.jar
/Users/myname/doc/src/dvcs/stanford-corenlp-full-2018-01-31/jollyday-0.4.9-sources.jar
但是当我运行它时,我收到以下错误。有人知道出了什么问题吗?感谢。
$ echo "the quick brown fox jumped over the lazy dog" > input.txt
$ java -mx3g edu.stanford.nlp.pipeline.StanfordCoreNLP -outputFormat json -file input.txt
Searching for resource: StanfordCoreNLP.properties
Searching for resource: edu/stanford/nlp/pipeline/StanfordCoreNLP.properties
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model
at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:493)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:81)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:260)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:127)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:123)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1251)
Caused by: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:749)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:283)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:247)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:78)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:62)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:491)
... 5 more
Caused by: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as either class path, filename or URL
at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:419)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:744)
... 10 more
答案 0 :(得分:0)
我在附近,但我记得你可能要设置环境。变量STANFORD_MODELS,包含模型文件xxx-models.jar的目录列表 它似乎是在线文档。 希望它可能有所帮助。