stanfordcorenlp 中的词干选项

Stemming option in stanfordcorenlp

问题:是否可以选择使用 stanford-core-nlp 来阻止单词? 我找不到一个!我正在使用 stanford-corenlp-3.5.2.jar.

代码:

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);
  }
}

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

这个class会提供你想要的:

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

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

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