Stanford CoreNLP: Use partial existing annotation

怎甘沉沦 提交于 2019-12-06 04:40:31

The exception is thrown due to unsatisfied requirement expected by "pos" annotator (an instance of POSTaggerAnnotator class)

Requirements for annotators which StanfordCoreNLP knows how to create are defined in Annotator interface. For the case of "pos" annotator there are 2 requirements defined:

  • tokenize
  • ssplit

Both of this requirements needs to be satisfied, which means that both "tokenize" annotator and "ssplit" annotator must be specified in annotators list before "pos" annotator.

Now back to the question... If you like to skip "tokenize" and "ssplit" annotations in your pipeline you need to disable requirements check which is performed during initialization of the pipeline. I found two equivalent ways how this can be done:

  • Disable requirements enforcement in properties object passed to StanfordCoreNLP constructor:

    props.setProperty("enforceRequirements", "false");

  • Set enforceRequirements parameter of StanfordCoreNLP constructor to false

    StanfordCoreNLP pipeline = new StanfordCoreNLP(props, false);

you should add the parameters "tokenize"

pipelineProps.put("annotators", "tokenize, pos, lemma, parse");
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!