1
import jieba
import jieba.posseg as psg
f = open('李白的诗.txt','r',encoding='utf-8')
lbPoetry=f.read()
f.close()
lst_poetry_word=psg.lcut(lbPoetry)
dic_one_noun={
}
dic_two_noun={
}
for x in lst_poetry_word:
if len(x.word)==1 and x.flag=='n':
dic_one_noun[x.word]=dic_one_noun.get(x.word,0)+1
if len(x.word)==2 and x.flag=='n':
dic_two_noun[x.word]=dic_two_noun.get(x.word,0)+1
result_one_noun=sorted(dic_one_noun.items(),key=lambda x:x[1],reverse=True)
result_one_noun=[x[0]+str