引述
前段时间二战托福,成绩还不错110+,直接分手美滋滋。转战GRE直接一脸懵好吧,选项里面一堆词见都没见过。故奋起而分期背之,然苦于单词表为鄙人手敲,难以自测,辗转反侧,久久难眠。今日罕见早起,时间颇为充裕,故手敲一轮子,以作分享。技术有限,多有纰漏,揖以贻笑大方而已。
功能
同目录下放你的单词表,csv文件,第一列英文第二列中文,其余随意。整体效果看起来是这样的
每次展示英文与选项,手敲选项,及时反馈正误,若错了给出正确意思。全部选完过后会告诉你你错了几个,正确率是多少。最后会在同文件夹下给出一个false_vocab.csv,里面记录了你选错的单词。
代码
import randomfile_path = 'GRE.csv'
false_vocab_path = 'false_vocab.csv'
choose_chinese = True # 是给英文选中文还是反之class word:def __init__(self, eng, chi):self.english = engself.chinese = chidef is_right_chinese(self, chinese):return chinese == self.chineseword_list = []
with open(file_path, 'r') as fin:for line in fin:ls = line.strip().split(',')eng = ls[0]chi = ls[1]crnt_word = word(eng, chi)word_list.append(crnt_word)start = 0
end = 100
word_list = word_list[start : end]
random.shuffle(word_list)
all_chinese = [w.chinese for w in word_list]
all_english = [w.english for w in word_list]def dictation(show_part, guess_part, choice_num=4): # 默认四个选项total_len = len(show_part)false = 0false_vocab = []for idx, (show, real_guess) in enumerate(zip(show_part, guess_part)):choices = random.sample(guess_part[:idx] + guess_part[idx+1:], choice_num-1)choices.append(real_guess)random.shuffle(choices)print(idx+1, ':', show)for i in range(choice_num):print(i,':',choices[i], end='\t')print()choose = choices[int(input())]if choose == real_guess:print('T')else:print('F', '\t', real_guess)false_vocab.append((show, real_guess))correction = 1.0 - false / total_lenprint('false choices count: ', false)print('correction :', correction)return false_vocabif choose_chinese:false_vocab = dictation(all_english, all_chinese)
else:false_vocab = dictation(all_chinese, all_english)with open(false_vocab_path, 'w') as fout:for (eng, chi) in false_vocab:fout.write(str(eng) + ', ' + str(chi) + '\n')
单词示例
「GRE.xlsx」https://www.aliyundrive.com/s/25rdQkdS2Bu 提取码: c8s5
阿里云不能分享csv有点难受,用excel转一下吧