实体提及检测无法与 TokensRegex 一起正常工作

Entity Mention Detection is not working properly with TokensRegex

entitymention 似乎不起作用。我按照此处提到的类似方法添加 entitymentions 作为 annotators

之一

输入:"Here is your 24 USD"

我有一个 TokensRegex:

{ ruleType: "tokens", pattern: ([{ner:"NUMBER"}] + [{word:"USD"}]), action: Annotate([=10=], 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([=10=], ner, "NEW_MONEY"), Annotate([=10=], 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

更多文档在这里:

https://stanfordnlp.github.io/CoreNLP/tokensregex.html

https://stanfordnlp.github.io/CoreNLP/ner.html