Пример #1
0
def v(rev=True, SS=False, L2=False, T=False, wt='', cat='', sl=0, exam=0):
    """Short for view, default to rank from the word you forgot the most times, pass any value to rank from reverse
    L2 = bilingual, SS = show score, rev = Reverse, T = by time order, wt = by word type, cat = by category, sl = score limit
    """
    target = sort_by_score(raw_dict.keys(), rev=rev, sl=sl)

    if T:
        target = sort_by_time(target)

    if L2:
        target = sort_by_bilingual(target)

    if wt:
        target = sort_by_word_type(target, wt)

    if cat:
        target = sort_by_category(target, cat)

    if exam:
        return target

    if not SS:
        for i in target:
            print i
    else:
        for i in target:
            print i, raw_dict[i].get('forget_score')
Пример #2
0
def exam(rev=True, L2=False, T=False, target = [], st=False):
    """Default to rank from the word you forgot the most times, pass any value to rank from reverse
    L2 = bilingual, rev = Reverse, T = by time order, st = test Sentence, you can use v() to pass a filtered target list to exam()
    """

    # sentence test begin

    if st:
        agent = show_st(exam=True)
        for index, sentence in agent:
            print sentence, '\n'
            answer = raw_input('You remember this sentence?')
            if answer in ['y', 'yes', 's', 'si']:
                st_dict[index]['forget_score'] -= 1
                add_score(1)
            else:
                st_dict[index]['forget_score'] += 1
                add_score(-2)
        save()
        return

    # sentence test end

    target = target or sorted(raw_dict.keys(), key=lambda x: raw_dict[x].get('create_time', datetime.datetime(2006, 07, 11, 21, 13, 29, 296140)) if T else raw_dict[x].get('forget_score') , reverse = rev)

    temp_L = []

    for i in target:
        if L2:
            if not raw_dict[i].get('spanish'):
                continue

        if L2:
            print '\n'
            print 'Please type the Spanish/English version of: ', i
            answer = raw_input('>>>')

            if answer == raw_dict[i]['spanish']:
                raw_dict[i]['forget_score'] -= 1
                add_score(1)
                print '\n'
                g(old_word=i)
            else:
                raw_dict[i]['forget_score'] += 1
                add_score(-2)
                temp_L.append(i)
                print '\n'
                g(old_word=i)
                print '\n'

        else:
            print '\n'
            print 'Do you remember: ', i, '?'
            answer = raw_input('type y for yes, and others for no: ')

            if answer == 'y' or answer == 'yes':
                raw_dict[i]['forget_score'] -= 1
                add_score(1)
                print '\n'
                g(old_word=i)
            else:
                raw_dict[i]['forget_score'] += 1
                add_score(-2)
                temp_L.append(i)
                print '\n'
                g(old_word=i)

    if temp_L:
        print 'These are the words you failed in this +xam, you can put more effort on them later.\n'
        for i in temp_L:
            print '\t\t', i

    save()