-
Notifications
You must be signed in to change notification settings - Fork 119
案例:数词频
Cheng-Jun Wang edited this page Sep 26, 2019
·
1 revision
https://plato.stanford.edu/entries/socrates/
with open('socrates.txt', 'r') as f:
lines = f.readlines()
story = ' '.join(lines)
story = story.replace('\n', '').replace('.', '').replace("’", '').replace(',', '').replace(':', '').replace('?', '')
story_list = story.split(' ')
word_dic = {i:0 for i in story_list}
for i in story_list:
word_dic[i] +=1