赞
踩
是一个数值计算包,
优点:
自然语言处理专用工具包,定义语法和逻辑推理
安装
pip3.6 install nltk
用来从文档中自动提取语意主题。含有很多非监督学习算法。
支持word2vec和Doc2vec,这个包相对nltk来说是比较高深的。
安装
pip3.6 install gensim
如果无法安装,我们可以下载后安装。
是全球最火热的深度学习框架,没有之一,主要用于图像处理和自然语言处理。
支持多GPU分布式计算。
安装:
pip3.6 install tensorflow
全模式:只要是词都会被切出来
b=jieba.cut(test,cut_all=True)
print(",".join(b))
引擎模式:词只要在邻近的位置都会被切出来
c=jieba.cut_for_search(test)
print(",".join(c))
精准模式:精确切分
import jieba
test="数据挖掘是一门很好的课程"
a=jieba.cut(test,cut_all=False)
print(",".join(a))
返回值是一个迭代器,为的是提高效率。
import jieba.posseg as pseg
string="我是一名优秀的数据挖掘工程师。"
words=pseg.cut(string)
for word,flag in words:
print("{},{}".format(word,flag))
我,r
是,v
一名,m
优秀,a
的,uj
数据挖掘,n
工程师,n
。,x
词性标注和返回词语在原文的启始位置。
可加入自定义字典
支持多种语言,简体和繁体都可以
可以做分词和词性识别的java工具包.
优点:
支持多种语言(包括中文)
在国际上分词准确率拿了第一
功能强大。词性和词形标注,可以做命名实体识别,句法分析,词法分析,情感分析。
提供了多种编程语言的接口
方便的简单的部署web服务
安装步骤
nlp=StanfordCoreNLP(r'.\tools\stanfordnlp',lang='zh')
fin=open('./data/news.txt','r',encoding='utf-8')
fner=open('./data/ner.txt','w',encoding='utf-8')
ftag=open('./data/pos_tag.txt','w',encoding='utf-8')
for line in fin:
line=line.strip() # 用于移除结尾或者开头的空白字符
if len(line)<1:
continue
fner.write(" ".join([each[0]+"/"+each[1] for each in nlp.ner(line) if len(each)==2])+"\n")
ftag.write(" ".join([each[0]+"/"+each[1] for each in nlp.pos_tag(line) if len(each)==2])+"\n")
fner.close()
ftag.close()
简介
是一系列模型和算法组成的java工具包.
目标是普及自然语言处理在生成环境中的应用.
HanLP具备工具完善,性能高效,架构清晰,语料时新,可自定义的特点。
功能
安装
安装java1.8和visualC++2015
pip3.6 install jpype 或者conda install -c conda-forge jpype1
测试是否安装成功:
from jpype import *
startJVM(getDefaultJVMPath(),"-ea")
java.lang.System.out.println("hello world")
shutdownJVM()
import jpype from time import * # 获取虚拟机路径 jvmPath = jpype.getDefaultJVMPath() # jpath = r'D:\SProgram\Java\Jdk8\jre\bin\server\jvm.dll' # 可见 获取jvmPath 与 jpath 一样。 print(jvmPath) # D:\SProgram\Java\Jdk8\jre\bin\server\jvm.dll # 启动虚拟机 jpype.startJVM(jvmPath) # 判断虚拟机是否启动 print(jpype.isJVMStarted()) # 调用java程序,执行打印 jpype.java.lang.System.out.println("hello JPype !") # 关闭虚拟机 jpype.shutdownJVM() sleep(5) print(jpype.isJVMStarted())
hanlp安装
pip install hanlp
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。