コード例 #1
0
def do_review(wordslist):
    np.random.shuffle(wordslist)
    words_done = []
    total_correct = 0
    total_incorrect = 0
    while True:
        if not wordslist:
            break
        print(Fore.CYAN + "\n{0} Questions to go. ".format(len(wordslist)))
        word = np.random.choice(wordslist)
        word_, is_correct, ans = do_review_one(word)
        if is_correct:
            wordslist.remove(word)
            total_correct += 1
            print(Fore.YELLOW + 'Correct')
            _say(np.random.choice(CORRECT_RES))
        else:
            total_incorrect += 1
            correct_word = word.answer
            print(Fore.RED +
                  'Incorrect. The Answer is : %s' % correct_word.upper())
            _say("{}. You wrote {}".format(np.random.choice(INCORRECT_RES),
                                           ans))
            _say("The Correct Answer is : ")
            _say(correct_word)
        words_done.append(word_)

    _say("You answered {} words correctly and {} words incorrectly".format(
        total_correct, total_incorrect))
    return words_done
コード例 #2
0
def do_test(test_words):
    correct = 0
    incorrect = 0
    total = len(test_words)
    incorrect_words = []
    save_selected_words = []
    while True:
        if not test_words:
            break
        print(Fore.CYAN + "\n{0} Questions to go. ".format(len(test_words)))
        word = np.random.choice(test_words)
        word_, is_correct, ans = do_test_one(word)
        save_selected_words.append(word_)
        if is_correct:
            correct += 1
            incorrect_words.append([word, ""])
        else:
            incorrect += 1
            if ans == "":
                ans = "____"
            incorrect_words.append([word, ans])
        test_words.remove(word)

    msg1 = "Your score is {} out of {} ".format(correct, total)
    msg2 = "You scored {:.1f} %".format(correct * 100 / total)
    print(msg1)
    print(msg2)
    _say(msg1)
    _say(msg2)
    print_correction(incorrect_words)
    return save_selected_words
コード例 #3
0
def print_next_review_day(fname):
    next_due_date = Deck(fname).get_next_review_day()
    text_msg = "Next review in {}".format(
        format_timedelta(next_due_date - datetime.now()))
    print(text_msg)
    if "-" not in text_msg:
        _say(text_msg)
    else:
        _say("Next Review is Now.")
        review_words(fname)
コード例 #4
0
def study_com(args):
    """
    Study command to study n number of words
    """
    deck = Deck(args.word_file)
    # selected_word = [word for word in wordslist if word.active is False]
    selected_word = deck.get_inactive_cards()
    if selected_word:
        for word in selected_word[:args.nwords]:
            word.toggle_active()
            word.reset_date()
            question = _change_question(word.question)
            print("\n", word.question)
            _say(question, 3)
            print("\t\t", word.answer.upper())
            _say(word.answer, 2)
        deck.save_words(selected_word)
コード例 #5
0
def _say_question_inner(word, sleepseconds=0.0):
    print("\n{} : ".format(word), end="")
    question = _change_question(word)
    # _say(question, sleepseconds)
    _say("The Question is {}".format(question), sleepseconds=sleepseconds)