Created
August 6, 2018 16:20
-
-
Save p3nj/0d6ba63bbd6dfb378288fac6cb86c4d4 to your computer and use it in GitHub Desktop.
歌詞歌詞詞頻統計
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lyrics = [] | |
while True: | |
i = input() | |
if i == '===': | |
break | |
i = i.split() | |
for j in i: | |
j = j.lower() | |
if j == "we're": | |
lyrics.append('we') | |
lyrics.append('are') | |
continue | |
if j == "i'd": | |
lyrics.append('i') | |
lyrics.append('would') | |
continue | |
j = j.replace('.', '').replace(':', '').replace('?', '').replace(',', '').replace('\n', '') | |
lyrics.append(j) | |
d = {} | |
for i in sorted(lyrics): | |
if i in d: | |
d[i] += 1 | |
continue | |
d[i] = 1 | |
for key, value in d.items(): | |
print('{}:{}'.format(key,value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment