[English word dictation] English word recitation aid

to quote

Some time ago in World War II TOEFL, the score was not bad at 110+, so I broke up directly. I was stunned when I moved to the GRE. Well, I have never seen a bunch of words in the options. So I got up and memorized it in stages, but I suffered from the fact that the word list was knocked out by my hands, it was difficult to test myself, I tossed and turned, and couldn't sleep for a long time. It is rare to get up early today, and I have plenty of time, so I knocked on a wheel to share. The technology is limited, and there are many flaws, which are just generous to make people laugh.

Function

Put your vocabulary list and csv file in the same directory, the first column is English and the second column is Chinese, and the rest are optional. The overall effect looks like this. insert image description here
Each time the English and options are displayed, the option is tapped by hand, and the correctness is given in time. If it is wrong, the correct meaning is given. After all the selections, it will tell you how many mistakes you made and the correct rate. Finally, a false_vocab.csv will be given in the same folder, which records the words you chose wrong.

the code

import random

file_path = 'GRE.csv'
false_vocab_path = 'false_vocab.csv'
choose_chinese = True  # 是给英文选中文还是反之

class word:
    def __init__(self, eng, chi):
        self.english = eng
        self.chinese = chi

    def is_right_chinese(self, chinese):
        return chinese == self.chinese


word_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 = 0
    false_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_len
    print('false choices count: ', false)
    print('correction :', correction)
    return false_vocab

if 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')
        

word example

"GRE.xlsx" https://www.aliyundrive.com/s/25rdQkdS2Bu Extraction code: c8s5
Aliyun can't share csv, it's a bit uncomfortable, use excel to transfer it

Guess you like

Origin blog.csdn.net/Petersburg/article/details/124702764