github:https://github.com/riverind
CSDN,https://blog.csdn.net/woai8339/article/details/131442801
微信公众号,leetcode_algos_life
小红书号:412408155
【问题描述】
PyLTP直接pip安装报错,报错信息如下:
ERROR: Could not build wheels for pyltp, which is required to install pyproject.toml-based projects
【解决方案】
直接源码安装,源码安装命令如下:
git clone https://github.com/HIT-SCIR/pyltp
cd ./pyltp
git submodule init
git submodule update
python setup.py install
【模型下载】
版本对应关系:
pyltp 版本:0.2.0
LTP 版本:3.4.0
模型版本:3.4.0
七牛云,当前模型版本 3.4.0
新建model文件夹,解压模型文件压缩包到model文件夹里
【初步测试】
from pyltp import Segmentor
segmentor = Segmentor(model_path="./model/ltp_data_v3.4.0/cws.model")
segmentor.load("./models/ltp_data_v3.4.0/cws.model")
print ("|".join(words))