5

Problem: Is there an option to stem the words using stanford-core-nlp? I am not able to find one! I am using the stanford-corenlp-3.5.2.jar.

Code:

public class StanfordNLPTester {

  public static void main (String args[]){

    String paragraph = "A long paragraph here";

    Properties properties = new Properties();
    properties.put("annotators","tokenize,ssplit,pos,lemma,ner,depparse");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(properties);
    Annotation annotation = new Annotation (paragraph);
    pipeline.annotate(annotation);
    pipeline.prettyPrint(annotation,System.out);
  }
}
4

1 回答 1

8

您需要从 GitHub 获取:https ://github.com/stanfordnlp/CoreNLP

这个类将提供你想要的:

https://github.com/stanfordnlp/CoreNLP/blob/master/src/edu/stanford/nlp/process/Stemmer.java

该类的 main() 方法显示了词干分析器的示例用法。

您可以继续使用 stanford-corenlp-3.5.2.jar 并只包含一个额外的类,因为该类所依赖的所有内容都在 jar 中。

于 2015-10-10T09:58:31.020 回答