运行Coref Stanford时出现NullPointerException

时间:2016-02-15 14:45:16

标签: java stanford-nlp

我想使用Stanford NLP的共指解决方案。我已经下载了最新版本3.6。但是当我运行以下代码时,我得到的是NullPointerException。我抬头看着网,似乎很少有人遇到同样的问题,但没有提到任何解决方案。任何帮助将不胜感激。

public static void main(String[] args) {
  Properties props = new Properties();
  props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
  props.put("dcoref.score", true);
  StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
  String sentence="Stanford University is located in California. It is a great university, founded in 1891.";
  Annotation document = new Annotation(sentence);

  pipeline.annotate(document);
  System.out.println(document);
  Map<Integer, CorefChain> graph = document.get(CorefChainAnnotation.class);
  Set<Integer> set=graph.keySet();
  Iterator <Integer> it=set.iterator();
  while(it.hasNext()) {
    CorefChain c=graph.get(it.next());
    System.out.println("CorefChain: "+c);
  }
}

0 个答案:

没有答案