Jon*_*est 26 stanford-nlp maven
当从Stanford CoreNLP网站构建示例应用程序时,我遇到了一个奇怪的例外:
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)
…
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
…
Run Code Online (Sandbox Code Playgroud)
这只发生在属性pos及其后的属性包含在属性中时.
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Run Code Online (Sandbox Code Playgroud)
这是我的pom.xml的依赖:
<dependencies>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
Jon*_*est 51
我实际上在Stackoverflow上的另一个问题的问题描述中找到了答案.
Maven不会自动下载模型文件,但仅限于将模型行添加到.pom中.这是一个.pom片段,可以获取代码和模型.
以下是我的依赖项现在的样子:
<dependencies>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.2.0</version>
<classifier>models</classifier>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
需要注意的重要部分是<classifier>models</classifier>底部的条目.为了让Eclipse来维持两个引用,你需要配置每个依赖stanford-corenlp-3.2.0和stanford-corenlp-3.2.0-models.
| 归档时间: |
|
| 查看次数: |
7970 次 |
| 最近记录: |