jieba库的安装

1
pip install jieba

jieba库的安装

jieba库的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import jieba.analyse

data = "Python 是一种解释型、面向对象、动态数据类型的高级程序设计语言。" \
"Python 由 Guido van Rossum 于 1989 年底发明,第一个公开发行版发行于 1991 年。"

#提取标签
for keyword,weight in jieba.analyse.extract_tags(data,withWeight=True):
print('%s:%s' % (keyword,weight))

#输出内容
# Building prefix dict from the default dictionary ...
# Loading model from cache C:\Users\10186\AppData\Local\Temp\jieba.cache
# Loading model cost 0.878 seconds.
# Prefix dict has been built successfully.
# Python:1.1385492859904762
# 数据类型:0.585297130452381
# Guido:0.5692746429952381
# van:0.5692746429952381
# Rossum:0.5692746429952381
# 1989:0.5692746429952381
# 1991:0.5692746429952381
# 发行版:0.5270221099
# 面向对象:0.5067895768571429
# 程序设计:0.44264321266619044
# 发明:0.31970364912190474
# 动态:0.3195238865542857
# 高级:0.3114256070914286
# 语言:0.29349988448285713
# 第一个:0.28425680430714284
# 解释:0.2720391527752381
# 年底:0.2701318006847619
# 公开:0.26735277138999997
# 发行:0.22793990734714284
# 一种:0.19674458076142856

评论





载入天数...载入时分秒...

Blog content follows the Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) License

Use WZH as theme, total visits times