stanford corenlp:加载标记模型时出现无法恢复的错误

时间:2015-03-06 15:31:31

标签: java eclipse stanford-nlp

我需要使用Java API来使用StanfordTruecaser。我有这段代码:

  String text = "i love paris. i am with barack obama";

  //define the properties of the pipeline to be run and add annotators to it
  Properties props = new Properties();
  props.put("annotators", "tokenize, ssplit, pos, lemma, ner, truecase");
  pipeline = new StanfordCoreNLP(props);

  //run annotators on document text
  Annotation document = new Annotation(text);
  pipeline.annotate(document);

但是POS标记器不能很好地工作:

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:558)
    at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:267)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:129)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:125)

我使用Eclipse并且我已经链接了 stanford-corenlp-3.4.jar ,如下所示: enter image description here

1 个答案:

答案 0 :(得分:1)

我只是将 stanford-corenlp-3.4-models.jar 添加到Eclipse中的类路径中,它可以正常工作。