Error in creating the StanfordCoreNLP object

三世轮回 提交于 2019-11-30 21:37:40

The exception which is thrown is due to the missing pos model. This is because there are downloadable versions with and without the model files.

Either you add stanford-postagger-full-3.3.1.jar which can be found on the following page (stanford-postagger-full-2014-01-04.zip): http://nlp.stanford.edu/software/tagger.shtml .

Or you do the same for the whole CoreNLP Package (stanford-corenlp-full....jar): http://nlp.stanford.edu/software/corenlp.shtml (Then you can drop all the postagger depenedencies too, they are included in CoreNLP)

In case you only want to add the model files, look at Maven Central and download "stanford-corenlp-3.3.1-models.jar".

An easier way to add those model files is to simply add following dependencies in your pom.xml and let maven manage it for you:

<dependency>
  <groupId>edu.stanford.nlp</groupId>
  <artifactId>stanford-corenlp</artifactId>
  <version>3.6.0</version>
</dependency>
<dependency>
  <groupId>edu.stanford.nlp</groupId>
  <artifactId>stanford-corenlp</artifactId>
  <version>3.6.0</version>
  <classifier>models</classifier> <!--  will get the dependent model jars -->
</dependency>

If anyone looking for gradle dependencies, add the following under dependencies.

 compile group: 'edu.stanford.nlp', name: 'stanford-corenlp', version: '3.9.1'
 compile group: 'edu.stanford.nlp', name: 'stanford-corenlp', version: '3.9.1', classifier: 'models'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!