stanford-nlp - 实体提及检测无法与 TokensRegex 一起正常工作
问题描述
entitymention 似乎不起作用。我遵循了此处提到的类似方法,将其添加entitymentions
为annotators
如何使用 CoreNLP 的 RegexNER 检测超过 1 个单词的命名实体?
输入:“这是你的 24 美元”
我有一个 TokensRegex:
{ ruleType: "tokens", pattern: ([{ner:"NUMBER"}] + [{word:"USD"}]), action: Annotate($0, ner, "NEW_MONEY"), result: "NEW_MONEY_RESULT" }
初始化管道:
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,tokensregex,entitymentions");
props.setProperty("tokensregex.rules", "basic_ner.rules");
我仍然有 2 个 CoreEntityMention 而不是只有 1 个。
它们都具有相同的值,edu.stanford.nlp.ling.CoreAnnotations$NamedEntityTagAnnotation
即NEW_MONEY
但他们有不同的 edu.stanford.nlp.ling.CoreAnnotations$EntityMentionIndexAnnotation
这是0
为了24
1
为了USD
由于它们都具有相同的实体标签注释,它们如何合并。
3.9.2
使用斯坦福图书馆的版本。
解决方案
问题是数字具有标准化的名称实体标签。
这是一个可以使用的规则文件:
# these Java classes will be used by the rules
ner = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$NamedEntityTagAnnotation" }
normNER = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$NormalizedNamedEntityTagAnnotation" }
tokens = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$TokensAnnotation" }
# rule for recognizing company names
{ ruleType: "tokens", pattern: ([{ner:"NUMBER"}] [{word:"USD"}]), action: (Annotate($0, ner, "NEW_MONEY"), Annotate($0, normNER, "NEW_MONEY")), result: "NEW_MONEY" }
您不应该在最后添加额外的tokensregex
注释器和entitymentions
注释器。注释器会将这些ner
作为子注释器运行。
这是一个示例命令:
java -Xmx10g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner -ner.additional.tokensregex.rules new_money.rules -file new_money_example.txt -outputFormat text
更多文档在这里:
推荐阅读
- c# - Audit.Net MVC - 如何解决 NullReferenceException?
- reactjs - 为什么在输入更改时重新渲染功能组件中的所有元素
- javascript - moment.utc('date string').format('DD-MMM-YYYY') 返回上一个日期
- c# - 在不同的机器 C# 中生成和签署证书
- jquery - JQuery .nextUntil() 选择标题进入 li
- javascript - 如何创建多个popper实例?
- r - 如果 X 中的列为 FALSE,则删除 Y 中的相同列?
- r - 错误:`position` 必须是字符串或位置对象,而不是具有类标签的 S3 对象
- ios - registerUserNotificationSettings 没有触发代表并且推送通知无法正常工作我的项目
- java - 垃圾收集如何识别孤立对象?