统计英文儿歌中出现的单词和次数
song=’’‘Twinkle, twinkle, littlestar,How I wonder what you are!Up above the world so high,Like a diamond in the sky.Twinkle, twinkle, little star,How I wonder what you are!When the blazing sun is gone,When he nothing shines upon,Then you show your little light,Twinkle, twinkle, all the night.Twinkle, twinkle, little star,How I wonder what you are!Then the travler in the darkThanks you for your tiny spark;How could he see where to go,If you did not twinkle so?Twinkle, twinkle, little star,How I wonder what you are!In the dark blue sky you keep, andThrough my curtains often peep,For you never shut your eyes,Till the morning sun does rise.Twinkle, twinkle, little star,How I wonder what you are!As your bright and tiny sparkLights the travler in the dark,Though I know not what you are,Twinkle on, please, little star.Twinkle, twinkle, little star,How I wonder what you are!
‘’’
song=song.lower().replace(’,’,’ ‘).replace(’.’,’ ‘).replace(’!’,’ ‘).replace(’?’,’ ')
list_song=song.split()
count={}
for i in list_song:
if i not in count:
count[i]=1
else:
count[i]+=1
print(sorted(count.items(),key=lambda item:item[1],reverse=True))