- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 CoreNLP 来注释多行英文文本中的 NE。执行以下操作时:
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner");
props.put("ssplit.newlineIsSentenceBreak", "always");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String contentStr = "John speaks with Martin\n\nJeremy talks to him too.";
Annotation document
= new Annotation(contentStr);
pipeline.annotate(document);
List<CoreMap> sents = document.get(SentencesAnnotation.class);
for (int i = 0; i < sents.size(); i++) {
System.out.println("sentence " + i + " "+ sents.get(i));
}
句子分割效果很好,可以识别两个句子。但是,当我使用 NER 分类时,如下所示:
CRFClassifier classifier = CRFClassifier.getClassifier("edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz", props);
String classifiedStr = classifier.classifyWithInlineXML(contentStr);
我收到以下错误消息:
Unknown property: |ssplit.newlineIsSentenceBreak| Unknown property: |annotators|
并且分类器似乎将所有文本视为一个句子,导致错误识别实体“Martin Jeremy”而不是两个不同的实体。
知道出了什么问题吗?
最佳答案
CRFClassifier.getClassifier
所采用的属性与 StanfordCoreNLP
构造函数所采用的属性不同,这就是您收到选项未知错误的原因。
它将被设置,但不会在运行时使用。
来自here ,你会发现需要设置SeqClassifierFlags
的属性。您需要设置tokenizerOptions
,并将选项设置为“tokenizeNLs = true”
,这会将新行视为标记。
底线,在获取分类器之前按如下方式设置属性。它不应该给您未知属性的错误,并且它应该按预期工作。
Properties props = new Properties();
props.put("tokenizerOptions", "tokenizeNLs=true");
CRFClassifier classifier = CRFClassifier.getClassifier("edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz", props);
String classifiedStr = classifier.classifyWithInlineXML(contentStr);
关于java - CRFClassifier 无法识别句子分割器选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33178029/
我正在使用 CoreNLP 来注释多行英文文本中的 NE。执行以下操作时: Properties props = new Properties(); props.put("annotators", "
我正在尝试使用斯坦福 NLP 库的 CRFClassifier。 经过训练的模型应该位于 .ser 文件中,但是当我将反序列化对象传递给 CRFClassifier 构造函数时,出现错误: java.
对于文档中的每个单词,我希望添加一系列 float 作为斯坦福 NER 的 CRFClassifier 进行训练的特征。不幸的是,斯坦福 NER 的 .prop 文件的文档并没有明确说明如何传入自定义
我正在使用 StanfordCoreNLP API 接口(interface)以编程方式执行一些基本的 NLP。我需要在自己的语料库上训练模型,但我想使用 StanfordCoreNLP 界面来完成它
我是一名优秀的程序员,十分优秀!