使用命令`hanlp`来验证安装:
C:\Users\Cab>hanlp
Downloading http://file.hankcs.com/hanlp/data-for-1.7.3.zip to g:\developinstall\anaconda3\lib\site-packages\pyhanlp\static\data-for-1.7.3.zip
1.68%, 10 MB, 384 KB/s, ETA 27 min 52 sFailed to download http://file.hankcs.com/hanlp/data-for-1.7.3.zip
Please refer to https://github.com/hankcs/pyhanlp for manually installation.
(手动安装请参考https://github.com/hankcs/pyhanlp。)
也就是自动安装失败,需要手动安装
------------------------------------------------------------------------------
开始配置:参考官方https://github.com/hankcs/pyhanlp/wiki/%E6%89%8B%E5%8A%A8%E9%85%8D%E7%BD%AE
1、首先自行下载 data 和 jar与配置文件 (在上面的链接有此链接去下载最新版),下载到 G:\developInstall\Anaconda3\Lib\site-packages\pyhanlp\static(static下)
2、下载完成之后,再次执行hanlp
C:\Users\Cab>hanlp
会自动解压,出现一下内容,安装成功
Using local g:\developinstall\anaconda3\lib\site-packages\pyhanlp\static\data-for-1.7.3.zip, ignore http://file.hankcs.com/hanlp/data-for-1.7.3.zip
Extracting data.zip...
usage: hanlp [-h] [-v] {segment,parse,serve,update} ...
HanLP: Han Language Processing v1.7.3
测试一下:
from pyhanlp import *
print(HanLP.segment("你好,欢迎使用HanLP汉语处理包!接下来请从其他Demo中体验HanLP丰富的功能~"))
结果:[你好/vl, ,/w, 欢迎/v, 使用/v, HanLP/nx, 汉语/gi, 处理/vn, 包/v, !/w, 接下来/vl, 请/v, 从/p, 其他/rzv, Demo/nx, 中/f, 体验/v, HanLP/nx, 丰富/a, 的/ude1, 功能/n, ~/nx]
学习手册:https://pypi.org/project/pyhanlp/