摩登家庭这部美剧学英语应该不模式,某宝上买了1~11季的台词,想对里面得单词出现频率做个统计,高频出现的单词应该就是日常常用的,应该牢牢记住。出现次数太低的也可以不用学了。
分析程序用的是python语言。
其中单词总量:23298个,分析结果以txt文本文件保存。词频结果下载
按流水号,单词,出现频率记录。如下:
1 i 32743
2 you 30923
3 the 23733
4 a 21256
5 to 20402
6 and 13428
7 it 12405
8 that 12020
9 of 9744
....
23291 conspiring 1
23292 subletting 1
23293 coughed 1
23294 overnighted 1
23295 biologist 1
23296 waitressing 1
23297 secret's 1
23298 muriel 1
出现次数最高的单词依然是i,you,the这类的。
代码如下:
1 import os 2 import re 3 4 from docx import Document 5 6 word_dic = {} 7 for root, dirs, files in os.walk(r'H:\english study'): 8 for file in files: 9 file_path = '{}\\{}'.format(root, file) 10 print(file_path) 11 doc = Document(file_path) 12 for para in doc.paragraphs: 13 # print(para.text) 14 rst = re.findall(r'\b[a-zA-Z\']+\b', para.text) 15 if rst: 16 for word in rst: 17 word = word.lower() 18 count = word_dic.get(word) 19 if count: 20 word_dic[word] = count + 1 21 else: 22 word_dic[word] = 1 23 sort_list = sorted(word_dic.items(), key=lambda x: x[1], reverse=True) 24 i = 1 25 26 with open('e:\\modern famile word sort.txt',mode='w',encoding='utf-8') as f: 27 for word in sort_list: 28 line='{} {} {}\n'.format(i, word[0], word[1]) 29 f.write(line) 30 i = i + 1 31 print('done, 单词总量:{}'.format(len(sort_list)))