代码很简单:
import spacy
from spacy import displacy
from collections import Counter
from pprint import pprint
import en_core_web_sm
nlp= spacy.load('en_core_web_sm')
doc= nlp('European to alter its practices')
pprint([(X.text, X.label_)for Xin doc.ents])
安装配置:
scapy旧用户pip安装就行
但是en_core_web_sm用pip不行,看教程从网上下了包安装后,运行程序报错:
raise source.error('bad escape %s' % escape, len(escape))
sre_constants.error: bad escape \p at position 257
没找到解决方法。就把en_core_web_sm卸了想重装,然后看到了这个教程:https://blog.csdn.net/u012436149/article/details/79321112
pip install spacy
python -m spacy download en
标签含义:
网友评论