在斯坦福覆盖 TokensRegex 的默认环境设置
Overriding default env settings for TokensRegex in stanford
超越 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(, ner, "IGNORE"), Annotate(, ner, "NUMBER"), Annotate([=10=], normalizedValue, "TOKENS_REGEX")), result: "NUMBER" }
您应该使用 GitHub 上的最新版本或版本 3.9.2。货币不再规范化,因此英镑符号将不再默认变成“#”。
你应该可以做类似的事情
originalWord = { type: "CLASS", value: edu.stanford.nlp.ling.CoreAnnotations$OriginalTextAnnotation }
然后您可以将规则中的 word
替换为 originalWord
。
超越 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(, ner, "IGNORE"), Annotate(, ner, "NUMBER"), Annotate([=10=], normalizedValue, "TOKENS_REGEX")), result: "NUMBER" }
您应该使用 GitHub 上的最新版本或版本 3.9.2。货币不再规范化,因此英镑符号将不再默认变成“#”。
你应该可以做类似的事情
originalWord = { type: "CLASS", value: edu.stanford.nlp.ling.CoreAnnotations$OriginalTextAnnotation }
然后您可以将规则中的 word
替换为 originalWord
。