问题描述
我运行 NLP 文本匹配算法。原来有时候运行成功后不显示输出。
import spacy
from spacy.matcher import Matcher
nlp = spacy.load("en_core_web_md")
matcher = Matcher(nlp.vocab,validate=True)
patterns = [{"LOWER": {"IN": ["self employed","average"]}},{"OP": "?"},{"LOWER": {"IN": ["self employed","average"]}}]
matcher.add("Self Employed",None,patterns)
doc = nlp(u"I am a self employed person with an average income; An average self employed project")
matches = matcher(doc)
for match_id,start,end in matches:
rule_id = nlp.vocab.strings[match_id] # get the unicode ID,i.e. 'CategoryID'
span = doc[start : end] # get the matched slice of the doc
print(rule_id,span.text)
是什么原因?有什么与算法有关的吗?谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)