【NLP】HanLP环境

1、参考:https://github.com/hankcs/pyhanlp

2、问题:

C:UsersADMINI~1AppDataLocalTemppip-install-u617cfx3jpype1setup.py:173: FeatureNotice: Turned ON Numpy support for fast Java array access
FeatureNotice)
building '_jpype' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

----------------------------------------
Command "d:programdataanaconda3python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-u617cfx3\jpype1\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace(' ', ' ');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersADMINI~1AppDataLocalTemppip-record-v70vznixinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersADMINI~1AppDataLocalTemppip-install-u617cfx3jpype1

3、解决方案:

--下载JPype1-0.6.3-cp36-cp36m-win_amd64.whl

--拷贝至:D:ProgramDataAnaconda3Scripts

--pip install JPype1-0.6.3-cp36-cp36m-win_amd64.whl

4、测试

5、使用

from pyhanlp import *

doc = "XXX"

for term in HanLP.segment(doc):
print('{}	{}'.format(term.word, term.nature)) # 获取单词与词性

输出:

D:ProgramDataAnaconda3python.exe E:/NLP/Code/hanlpdemo02.py
XXX
原文地址:https://www.cnblogs.com/defineconst/p/10155588.html