python – Spacy PhraseMatcher值错误模式长度(11)> = phrase
发布时间:2020-12-20 11:04:11 所属栏目:Python 来源:网络整理
导读:初始化带有术语列表的新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.vo
初始化带有术语列表的新PhraseMatcher时出现以下错误:
patterns = [nlp(org) for org in fields] self.matcher = PhraseMatcher(nlp.vocab) self.matcher.add('FIELD',None,*patterns) 解决方法
目前,单个规则的长度不能超过10个令牌:
# Allowed 'one two three four five six seven eight nine ten' # Not Allowed 'one two three four five six seven eight nine ten eleven' 您可以尝试将限制设置得更高,即:self.matcher = PhraseMatcher(nlp.vocab,max_length = 20),但当前版本的SpaCy 10中的iirc是硬限制. 请参阅https://spacy.io/api/phrasematcher#init的相关文档和https://github.com/explosion/spacy/blob/master/spacy/matcher.pyx#L452的源文档 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |