在使用术语列表初始化新的PhraseMatcher时,出现以下错误:
ValueError: Pattern length (11) >= phrase_matcher.max_length (10). Length can be set on initialization, up to 10.
patterns = [nlp(org) for org in fields]
self.matcher = PhraseMatcher(nlp.vocab)
self.matcher.add('FIELD', None, *patterns)
在spacy2.1.4版本中,上述短语匹配器的值错误已得到解决。如果您遇到这样的错误,请更新spacy版本。 参考:github issue link
您可以尝试将类定义为实体匹配器并在各种模式/字段上循环
目前,单个规则的长度不能超过10个标记:
您可以尝试设置更高的限制,例如:
self.matcher = PhraseMatcher(nlp.vocab, max_length=20)
,但是spacy10当前版本中的iirc是一个硬限制。在请参阅https://spacy.io/api/phrasematcher#init上的相关文档和位于https://github.com/explosion/spacy/blob/master/spacy/matcher.pyx#L452的源代码
相关问题 更多 >
编程相关推荐