安装 pip install spacy
下载语言库
2.1:英文 = python -m spacy download en_core_web_sm
2.2:中文 = python -m spacy download zh_core_web_sm
可以手动下载包再安装
下载地址 = https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.7.0/zh_core_web_sm-3.7.0-py3-none-any.whl
下载好之后执行命令:pip install zh_core_web_sm-3.7.0-py3-none-any.whl
代码例子
import spacy
nlp = spacy.load(‘zh_core_web_sm’)
doc = nlp(“今天温州温度多少”)
for token in doc:
print(token.text, “–>”, token.pos_)