1. 程式人生 > >Hanlp 在Python環境中安裝、介紹及使用

Hanlp 在Python環境中安裝、介紹及使用

Hanlp
HanLP是由一系列模型與演算法組成的Java工具包,目標是普及自然
語言處理在生產環境中的應用。HanLP具備功能完善、效能高效、架構
清晰、語料時新、可自定義的特點。
功能:中文分詞 詞性標註 命名實體識別 依存句法分析 關鍵詞提取
新詞發現 短語提取 自動摘要 文字分類 拼音簡繁

 

Hanlp環境安裝
• 1、安裝Java和Visual C++:我裝的是Java 1.8和Visual C++ 2015。
• 2、安裝Jpype,conda install -c conda-forge jpype1
• 3、測試是否按照成功:
from jpype import *
startJVM(getDefaultJVMPath(), "-ea")


java.lang.System.out.println("Hello World")
shutdownJVM()

 

Hanlp安裝
• 1)下載hanlp.jar包: https://github.com/hankcs/HanLP
• 2、下載data.zip:https://github.com/hankcs/HanLP/releases中
http://hanlp.linrunsoft.com/release/data-for-1.7.0.zip後解壓資料
包。
• 3、配置檔案
• 示例配置檔案:hanlp.properties
• 配置檔案的作用是告訴HanLP資料包的位置,只需修改第一行:
root=usr/home/HanLP/


• 比如data目錄是/Users/hankcs/Documents/data,那麼
root=/Users/hankcs/Documents/