【发布时间】:2014-10-07 21:14:47
【问题描述】:
我们正在尝试使用现有的
- 标记化
- 分句
- 和命名实体标记
虽然我们想使用 Stanford 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"
我们如何实现我们想要做的任何指针?
【问题讨论】:
-
当我构建这样的文档并传递给
CoreMapExpressionExtractor.createExtractorFromFiles(env, rulesFiles).extractExpressions(sentence)时,我无法获得任何匹配的表达式。这里我没有使用pipeline.annotate。但是,通常通过pipelineProps.setProperty("annotators", "tokenize, ssplit")传递文本会导致matchedExpressions = somevalue。有什么想法吗?
标签: nlp stanford-nlp