本文使用的代码和操作都很简单,很适合刚学习Python的小白参考,需要注意的事项都在文章尾部说明了,可以注意一下。
1.词频分析
1)代码:
import jieba
def wordFreq(filepath,text,topn):
words = jieba.lcut(text.strip())
counts = {}
stopwords = {'他','他们','一个','这里','那里','他们','没有','已经','选手','战队','就是','但是','已经','只是','技能','攻击','还是','现在'}
for word in words:
if len(word) == 1:
continue
elif word not in stopwords:
if word == "散人" or word == "大神" or word == "老大" or word == "叶修" or word == "老叶" or word=='君莫笑':
word = "叶秋"
elif word == "沐雨橙风" or word == "枪炮师" or