Spacy \ Matcher \ set成员资格引发异常

时间:2018-11-06 16:04:14

标签: spacy

我使用Spacy 2.7: 遵循Set Membership示例: 我用IN逻辑尝试了以下内容-简单的单词列表...

doc = nlp(SOME_TEXT)
matcher = Matcher(nlp.vocab)
pattern = [{'LOWER': {'IN' : ["i","you","we","they"]}}]
matcher.add("myPattern",None, pattern)
matches = matcher(doc) 
...

获取例外

would:[{'LOWER': {'IN': ['i', 'you', 'we', 'they']}}] with index 0
Traceback (most recent call last):
  File "test.py", line 85, in <module>
    matcher.add(key,None, curr)
  File "matcher.pyx", line 266, in spacy.matcher.Matcher.add
  File "matcher.pyx", line 99, in spacy.matcher.init_pattern
TypeError: an integer is required

转到开源文件(matcher.pyx)-在第99行中,不确定是什么错误,或者我使用的是错误的..

1 个答案:

答案 0 :(得分:0)

很抱歉,如果这样做令人困惑,但是您指的GitHub thread仍然只是规范和提案,即计划中的实施方案。希望这些更改将随spaCy v2.1.0一起提供(因为对Matcher内部的某些更改不完全向后兼容)。