stanford-nlp - 覆盖斯坦福 TokensRegex 的默认环境设置
问题描述
添加令牌正则表达式规则时edu.stanford.nlp.ling.CoreAnnotations$TextAnnotation
要
覆盖的设置是什么。edu.stanford.nlp.ling.CoreAnnotations$OriginalTextAnnotation
示例:
#123456
在斯坦福大学被标记为 MONEY,因此为了超越 NER 行为,我编写了标记123456
为 NUMBER 而不是 MONEY 的规则。作为副作用,以下£20.49
现在被标记为 NUMBER。
我调试了代码并意识到应用模式时edu.stanford.nlp.ling.CoreAnnotations$TextAnnotation
用于匹配。因此,在什么情况下£20.49
,输入£
是 的值,edu.stanford.nlp.ling.CoreAnnotations$OriginalTextAnnotation
并且#
是 的值edu.stanford.nlp.ling.CoreAnnotations$TextAnnotation
。
是否有环境设置来改变这种行为?
示例规则
# make all patterns case-sensitive
ENV.defaultStringMatchFlags = 0
ENV.defaultStringPatternFlags = 0
# these Java classes will be used by the rules
ner = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$NamedEntityTagAnnotation" }
tokens = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$TokensAnnotation" }
normalizedValue = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$NormalizedNamedEntityTagAnnotation" }
{ ruleType: "tokens", pattern: (([{word:"#"}]) ([{ner:"MONEY"}])), action: (Annotate($1, ner, "IGNORE"), Annotate($2, ner, "NUMBER"), Annotate($0, normalizedValue, "TOKENS_REGEX")), result: "NUMBER" }
解决方案
您应该使用 GitHub 上的最新版本或版本 3.9.2。货币不再规范化,所以英镑符号将不再默认变成“#”。
你应该能够做类似的事情
originalWord = { type: "CLASS", value: edu.stanford.nlp.ling.CoreAnnotations$OriginalTextAnnotation }
然后你可以word
在你的规则中替换为originalWord
.
推荐阅读
- javascript - javascript canvas 中的 ctx 未定义
- asp.net-core - 导航返回时表单保留值
- python - Pandas DateTime 仅部分显示在 Matplotlib 中
- react-native - 如果应用程序被用户关闭,则 React Native 简单的本地模块打开应用程序
- swift - 线程 1:EXC_BAD_ACCESS(代码=1,地址=0x879bb6700)(CoreData)
- angular - 在异步管道解决之前,数组为空
- google-bigquery - Google Big Query - 根据多个日期条件按状态计算每月总计
- html - 包装一个 flexbox 以允许最大的子缩放,同时保留纵横比
- java - paintComponent 覆盖像素
- c# - Linq 对字符串值进行左连接,从 Oracle 数据库中获取不正确的数据