【发布时间】:2015-03-06 15:31:30
【问题描述】:
我需要通过 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);
但是词性标注器不好用:
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:
【问题讨论】:
-
不,该怎么做?
-
您是否也下载了正确的 models.jar 并将其添加到您的类路径中?
-
我忘记了models.jar。现在可以了。
标签: java eclipse stanford-nlp