当前位置:网站首页>知识图谱 — jieba、pyhanlp、smoothnlp工具实现中文分词(词性表)
知识图谱 — jieba、pyhanlp、smoothnlp工具实现中文分词(词性表)
2022-07-27 16:12:00 【zkkkkkkkkkkkkk】
最近也是在预研知识图谱相关技术。这里面涉及到了一些关于自然语言处理方面的内容和技术。目前已经调研了一些分词、命名体识别相关技术。今天记录下分词工具的使用。
一、什么是知识图谱?
笔者理解的知识图谱是一个巨型的语义网络,形同互联网一样。不过语义网络上每个点是一个实体,两两实体之前存在一条边也就是关系或属性。其实也就是找到一个三元组,类似于(实体、关系、实体)或(实体、属性、属性值)的形式。这里面重要的步骤就是如何把形同这样形式的三元组抽取出来,并且还要保证抽取出三元组的正确性。这无疑是一个巨大的挑战。
二、知识图谱流程图
流程图是按照自己理解画的,有什么地方不妥欢迎指正!(大佬轻喷)

三、知识图谱的框架(工具)有哪些?
目前了解到已有知识图谱开源框架,如:deepke、bert、cndeepdive等等。
①:deepke是浙江大学知识引擎实验室开源的中文关系抽取开源框架。
该项目的官方地址:https://github.com/zjunlp/deepke/
②:bert是谷歌的一个开源框架。
该项目的官方地址:https://github.com/google-research/bert
③:deepdive是斯坦福大学的一个开源知识抽取框架,不过早在2017年就处于维护模式了。
该项目的官方地址:https://github.com/HazyResearch/deepdive
四:使用工具实现文本分词
了解到的jieba、pyhanlp、smoothnlp都可以中文分词,下面将一一介绍三个工具。
①:jieba分词
直接 pip install jieba 安装是很快的。
import jieba
import jieba.posseg as pseg
def postag(text):
words = pseg.cut(text)
return words
# 定义文本
text = 'jieba的主要功能是做中文分词,可以进行简单分词、并行分词、命令行分词,当然它的功能不限于此,目前还支持关键词提取、词性标注、词位置查询等。更让人愉悦的是jieba虽然立足于python,但同样支持其他语言和平台,诸如:C++、Go、R、Rust、Node.js、PHP、 iOS、Android等。所以jieba能满足各类开发者的需求'
# 句子已逗号分隔
jieba_list = []
sentence = text.split('。')
for i in range(len(sentence)):
word = postag(sentence[i]) #分词
for w in word:
# w这里有两个属性,分别为:w.flag==词性;w.word==词
jieba_list.append([w.flag,w.word])
# 输出jieba分词列表
print(jieba_list) ②:pyhanlp分词
值得注意的是运行pyhanlp的时候需要本地按照java环境,因为是它是调用java接口的。
from pyhanlp import *
text = 'jieba的主要功能是做中文分词,可以进行简单分词、并行分词、命令行分词,当然它的功能不限于此,目前还支持关键词提取、词性标注、词位置查询等。更让人愉悦的是jieba虽然立足于python,但同样支持其他语言和平台,诸如:C++、Go、R、Rust、Node.js、PHP、 iOS、Android等。所以jieba能满足各类开发者的需求'
# 句号分割
sentence = text.split('。')
pyhanlp_list = []
for i in range(len(sentence)):
pyhanlp_list.append(HanLP.segment(sentence[i]))
# 输出pyhanlp分词结果
print(pyhanlp_list)
③:smoothnlp分词
这个直接 pip install smoothnlp 即可。
from smoothnlp.algorithm.phrase import extract_phrase
text = 'jieba的主要功能是做中文分词,可以进行简单分词、并行分词、命令行分词,当然它的功能不限于此,目前还支持关键词提取、词性标注、词位置查询等。更让人愉悦的是jieba虽然立足于python,但同样支持其他语言和平台,诸如:C++、Go、R、Rust、Node.js、PHP、 iOS、Android等。所以jieba能满足各类开发者的需求'
# 句子以句号分割
sentence = text.split('。')
smoothnlp_list = []
for i in range(len(sentence)):
smoothnlp_list.append(extract_phrase(sentence[i]))
# 输出smoothnlp分词结果
print("smoothnlp:",a)
五、词性表
点击进入 常用词词性表 查看即可
六、总结
今天主要记录下分词工具的使用,顺便介绍了下自己理解的知识图谱。下篇文章会记录下关于命名体识别的相关技术与思想。点击进入:命名体识别文章
边栏推荐
- Marvell announced the roadmap of its arm server chip, and the performance of the next generation will be twice that of thunderx2
- 3. opencv几何变换
- uniapp运行到手机(真机调试)
- Binary tree concept
- [mit 6.s081] LEC 8: page faults notes
- File path read
- [MIT 6.S081] Lab 10: mmap
- 2021.7.22笔记 约束
- 2021.7.17笔记 mysql其他命令
- Please ask the great God a question, flinkcdc, the datetime field in synchronous MySQL will become a timestamp. Has anyone ever encountered it
猜你喜欢

multi-table query
![[MIT 6.S081] Lab 9: file system](/img/f5/ea30b1fe5b6d73c86f2509c690ca20.png)
[MIT 6.S081] Lab 9: file system

Deep recognition: thesis reading_ 2s-agcn cvpr2019 (two stream adaptive graph convolution network based on skeleton action recognition)
![[MIT 6.S081] Lab 7: Multithreading](/img/f4/26e513fb8678a88cfba29c1a636b37.png)
[MIT 6.S081] Lab 7: Multithreading

2. Change color space and color detection

2021.8.1笔记 数据库设计
![[mit 6.s081] LEC 4: page tables notes](/img/30/f1e12d669b656a0b14aa8c7b210085.png)
[mit 6.s081] LEC 4: page tables notes

Deep learning - paper reading: action structural graph convolution network as-gcn
![[MIT 6.S081] Lab 4: traps](/img/8b/ca4819f8b1cfc6233745a124790674.png)
[MIT 6.S081] Lab 4: traps

NowCoder(5选)
随机推荐
[mit 6.s081] LEC 5: calling conventions and stack frames risc-v notes
LootCode动态数组练习(724,118,766)
@Considerations for query of convert annotation in JPA
2021.7.12 internal and external connection of notes
How do corporate giants such as Schneider Electric and L'Oreal make open innovation? Uncover secrets of demo World Innovation Summit
Uniapp has no effect on the page selector on the app side
2021.7.19笔记 DML
[MIT 6.S081] Lec 3: OS organization and system calls 笔记
动态链表4单向循环链表(LoopSingle实现)
[MIT 6.S081] Lab 10: mmap
OEM "made in the United States", domestic security equipment has been installed on the U.S. aircraft carrier!
Technology sharing | quick intercom integrated dispatching system
[MIT 6.S081] Lab 11: networking
2021.8.9笔记 request
[MIT 6.S081] Lec 5: Calling conventions and stack frames RISC-V 笔记
记一次 .NET 某智慧物流 WCS系统 CPU 爆高分析
深度学习:GCN案例
Deep learning - VIDEO behavior recognition: paper reading - two stream revolutionary networks for action recognition in videos
[MIT 6.S081] Lec 10: Multiprocessors and locking 笔记
[MIT 6.S081] Lab 11: networking