Python jieba 分词+词频统计

利用jieba进行分词  

import jieba
sentence = '橘子香蕉橙子苹果柚子橘子橙子柚子苹果火龙果橙子香蕉香蕉橘子橙子柚子苹果火龙果柚子苹果火龙果橙子香蕉柚子橘子橙子柚子苹果苹果柚子橘子橙子柚子苹果橙子柚子苹果火龙果橙子香蕉香蕉橘子橙子柚子苹果火龙果'
seg = list(jieba.cut(sentence, cut_all=False))
print(seg)

词频统计

from collections import Counter
seg = Counter(seg)
seg.most_common()#默认查看所有类计数,seg.most_common(2)查看前两位计数

OK!

你可能感兴趣的:(Python jieba 分词+词频统计)