其他分享
首页 > 其他分享> > jieba

jieba

作者:互联网

Python中文分词库jieba(结巴分词)详细使用介绍

jieba这个库平时用的比较少,在这进行记录,上面的链接讲的比较全面。

1:补充一下判断词性的用法

>>> import jieba.posseg
>>> str = "前端,Vue props用法小结原"
>>> jieba.posseg.lcut(str)
Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 0.598 seconds.
Prefix dict has been built successfully.
[pair('前端', 'f'), pair(',', 'x'), pair('Vue', 'eng'), pair(' ', 'x'), pair('props', 'eng'), pair('用法', 'n'), pair('小结', 'n'), pair('原', 'n')]
>>> 
>>> seg_list = jieba.posseg.lcut(str)
>>> for seg in seg_list:
...     print(seg.word)
...     print(seg.flag)
...     break
... 
前端
f
>>> 

 词性对照表:

 

标签:...,jieba,posseg,seg,str,pair
来源: https://www.cnblogs.com/Live-up-to-your-youth/p/16544376.html