在带有二进制标志的SpaCy Matcher模式中使用自定义实体

时间:2019-01-17 22:29:13

标签: entity spacy matcher

我试图在基于规则的Matcher模式中包括自定义实体。我的想法是使用二进制标志,类似于在Matcher模式中包含正则表达式时如何使用它们。

我在github问题(https://github.com/explosion/spaCy/issues/1499)中找到了此代码段:

# get ID for custom flag and add getter (in this case, it just returns length of token text)
IS_TEST = nlp.vocab.add_flag(lambda text: text in ['test', 'testing']) # needs to be binary!
pattern = [{'SHAPE': 'dd'}, {IS_TEST: True}]

但是,我不想提供可能的匹配项作为列表(“测试”,“测试”),而是利用在先前的管道组件中创建的实体类型,例如entity_type ='TEST'。

如何基于以前的管道组件中已注释的自定义实体创建二进制标志?

任何支持我都会很高兴!

最诚挚的问候

0 个答案:

没有答案