综合练习:英文词频统计

 1 song = '''During my childhood, think lucky money and new clothes are necessary for New Year, but as the advance of the age, will be more and more found that those things are optional; Junior high school, thought to have a crush on just means that the real growth, but over the past three years later, his writing of alumni in peace, suddenly found that isn't really grow up, it seems is not so important; Then in high school, think don't want to give vent to out your inner voice can be in the high school children of the feelings in a period, but was eventually infarction when graduation party in the throat, later again stood on the pitch he has sweat profusely, looked at his thrown a basketball hoops, suddenly found himself has already can't remember his appearance.
 2     '''
 3 symbol = list(''',.?!’:"“”-%$''')
 4 for i in symbol:
 5     song = song.replace(i, ' ')
 6 song = song.lower()
 7 split = song.split()
 8 word = {}
 9 for i in split:
10     count = song.count(i)
11     word[i] = count
12 words = '''
13 you to for my i of a is the  what me but konw so no we sweet oh 
14 '''
15 prep = words.split()
16 for i in prep:
17     if i in word.keys():
18         del(word[i])
19 word = sorted(word.items(), key=lambda item: item[1], reverse=True)
20 for i in range(10):
21     print(word[i])

 

posted @ 2018-03-26 21:56  186-叶晓钿  阅读(141)  评论(0编辑  收藏  举报