修改这个程序,不能和原版一样,搞了一天没看出来(ಥ_ಥ)

import jieba

def stopwordslist(filepath):
stopwords = [line.strip() for line in open(filepath, 'r', encoding='utf-8').readlines()]
print(stopwords)
return stopwords

def getText(filepath):
f = open(filepath, "r",encoding='utf-8')
text = f.read()
f.close()
return text

def wordFreq(filepath,text,topn):
words = jieba.lcut(text)
counts = {}
stopwords = stopwordslist('stop_words.txt')
for word in words:
if len(word)==1:
continue
elif word not in stopwords:
if word == "诸葛亮" or word == "孔明曰":
rword = "孔明"
elif word == "关公" or word == "云长":
rword = "关羽"
elif word == "玄德" or word == "玄德曰":
rword = "刘备"
elif word == "孟德" or word == "丞相":
rword = "曹操"
else:
rword = word
counts[rword] = counts.get(rword,0) + 1
items = list(counts.items())
items.sort(key=lambda x:x[1], reverse=True)
f = open(filepath[:-4]+'_词频.txt', "w")
for i in range(topn):
word, count = items[i]
f.writelines("{0:<10}{1:>5}\n".format(word, count))
f.close()

text=getText('三国演义.txt')
wordFreq('三国演义.txt',text,20)
print('统计结束')

代码运行中有什么问题?检查代码缩进,最好用编辑窗口的插入代码块方式提供代码。