我们正在尝试利用现有的
同时我们希望使用斯坦福 CoreNlp 额外为我们提供
目前,我们正在尝试以下方式:
1)为“pos、lemma、parse”创建一个注释器
Properties pipelineProps = new Properties();
pipelineProps.put("annotators", "pos, lemma, parse");
pipelineProps.setProperty("parse.maxlen", "80");
pipelineProps.setProperty("pos.maxlen", "80");
StanfordCoreNLP pipeline = new StanfordCoreNLP(pipelineProps);
2)读入句子,使用自定义方法:
List<CoreMap> sentences = getSentencesForTaggedFile(idToDoc.get(docId));
在该方法中,令牌的构造方式如下:
CoreLabel clToken = new CoreLabel();
clToken.setValue(stringToken);
clToken.setWord(stringToken);
clToken.setOriginalText(stringToken);
clToken.set(CoreAnnotations.NamedEntityTagAnnotation.class, neTag);
sentenceTokens.add(clToken);
它们被组合成这样的句子:
Annotation sentence = new Annotation(sb.toString());
sentence.set(CoreAnnotations.TokensAnnotation.class, sentenceTokens);
sentence.set(CoreAnnotations.TokenBeginAnnotation.class, tokenOffset);
tokenOffset += sentenceTokens.size();
sentence.set(CoreAnnotations.TokenEndAnnotation.class, tokenOffset);
sentence.set(CoreAnnotations.SentenceIndexAnnotation.class, sentences.size());
3)句子列表被传递到管道:
Annotation document = new Annotation(sentences);
pipeline.annotate(document);
但是,当运行此程序时,我们收到以下错误:
null: InvocationTargetException: annotator "pos" requires annotator "tokenize"
有什么指示我们如何才能实现我们想要做的事情吗?