【问题标题】:Rule-based NER in Spacy: Remove patternsSpacy 中基于规则的 NER:删除模式
【发布时间】:2020-03-11 14:47:46
【问题描述】:

我一直在为我的自定义 Spacy 命名实体识别模型添加规则,使用新的 EntityRuler (https://spacy.io/usage/rule-based-matching#entityruler)。

我添加了 100 万个蛋白质名称,这需要几个小时才能运行,现在我意识到其中许多名称都是常用词(如“FOR”和“11”)。

我想从 EntityRuler 对象 (https://spacy.io/api/entityruler) 中删除一些模式。但我不知道该怎么做......

如何从我的 EntityRuler 对象中删除规则/模式? 无需卸载所有内容并加载应保留的内容。

【问题讨论】:

    标签: python machine-learning nlp spacy named-entity-recognition


    【解决方案1】:

    查看源代码 (https://github.com/explosion/spaCy/blob/master/spacy/pipeline/entityruler.py),EntityRuler 对象将模式直接传递给 Matcher 对象。您可以按如下方式轻松访问 EntityRuler 的 Matcher 对象(假设您的 EntityRuler 对象称为 entity_ruler):

    matcher = entity_ruler.matcher
    

    Matcher 对象具有删除模式/规则的方法,如 API (https://spacy.io/api/matcher) 中所述。因此,您可以通过键入删除模式

    matcher.remove(<insert pattern ID here>)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-02
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 2017-12-03
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      相关资源
      最近更新 更多