Exemplo n.º 1
0
 def conjugate(self, word):
     if type(word) is str:
         query = f"SELECT tense_id FROM tenses WHERE tense = \'{word}\'"
         tense_id = command(query, '', '')[0][0]
     else:
         tense_id = word
     return self.conjugation[tense_id](self.inf)
Exemplo n.º 2
0
def present(verb):
    query = "SELECT present1,present2,present3,present4,present5,present6,is_reflective FROM verbs WHERE inf = (%s)"
    data = (verb, )
    conjugated_verb = command(query, data, '')[0]
    sp = load_pronouns()
    conj_list = []
    sp_col = 2
    if conjugated_verb[6]:
        for i in range(0, 8):
            sp[i] = list(sp[i])
            sp[i][4] = sp[i][2] + ' ' + sp[i][4]
            sp[i][5] = sp[i][2] + ' ' + sp[i][5]
        if vowel(verb):
            sp_col = 5
        else:
            sp_col = 4
    for i in range(0, 6):
        if i == 0:
            if vowel(verb) and not conjugated_verb[6]:
                conj_list.append('j\'' + conjugated_verb[i])
            else:
                conj_list.append(sp[i][sp_col] + ' ' + conjugated_verb[i])
        if i == 1:
            conj_list.append(sp[i][sp_col] + ' ' + conjugated_verb[i])
        if i == 2:
            conj_list.append(sp[i + randint(0, 1)][sp_col] + ' ' +
                             conjugated_verb[i])
        if 2 < i < 5:
            conj_list.append(sp[i + 1][sp_col] + ' ' + conjugated_verb[i])
        if i == 5:
            conj_list.append(sp[i + randint(1, 2)][sp_col] + ' ' +
                             conjugated_verb[i])
        if conj_list[i].count(' ') > 1:
            conj_list[i] = ''.join(conj_list[i].rsplit(" ", 1))
    return conj_list
Exemplo n.º 3
0
def date():
    query = "SELECT * FROM dates"
    dates = command(query, '', '')
    score = 0
    for i in range(0, 6):
        entry = dates[randint(0, len(dates) - 1)]
        score = single_answer(entry, 1, 2, 3, score, True)

    score_line = f"Score: {score}/5"
    result = [score == 5, score_line]
    return result
Exemplo n.º 4
0
def numbers(number, list):
    #form number from 1 - 999
    if number < 101:
        query = "SELECT num_word FROM numbers WHERE nums = (%s)"
        data = (number, )
        return command(query, data, '')[0][0]
    else:
        num_str = str(number)
        num_dict = dict(list)
        if num_str[0] != 1:
            result = num_dict[int(num_str[0])] + ' cents ' + num_dict[int(
                num_str[1:])]
            result = result.replace(' zéro', '')
        else:
            result = "cent " + num_dict[int(num_str[1:])]
        return result
Exemplo n.º 5
0
def number1000():
    result = []
    score = 0
    for _ in range(0, 10):
        number = randint(0, 9999999999)
        correct_ans = ''
        if number < 101:
            correct_ans = numbers(number, [])
        else:
            query = "SELECT nums, num_word FROM numbers"
            num_list = command(query, '', '')
            num_str = str(number)
            str_slices = [
                num_str[-1 - i:-4 - i:-1][::-1]
                for i in range(0, len(num_str), 3)
            ]
            addition = [' mille', ' million', ' milliard']
            for i in range(len(str_slices) - 1, 0, -1):
                if int(str_slices[i]) == 0:
                    continue
                correct_ans = correct_ans + " " + numbers(
                    int(str_slices[i]),
                    num_list) + addition[i - len(str_slices) + 3]
                if int(str_slices[i]) > 1 and addition[i - len(str_slices) +
                                                       3] != ' mille':
                    correct_ans = correct_ans + 's'
            correct_ans = correct_ans + " " + numbers(int(str_slices[0]),
                                                      num_list)
        correct_ans = correct_ans[1:]
        if 'un mille' in correct_ans and not 'et un mille' in correct_ans:
            correct_ans = correct_ans.replace('un mille', 'mille')
        answer = input(f"{number}: ")
        if answer == correct_ans:
            print("Correct")
            score += 1
        else:
            print("Wrong")
            print(f"{number}: {correct_ans}")
    score_line = f"Score: {score}/10"
    result.append(score == 10)
    result.append(score_line)
    return result
Exemplo n.º 6
0
def country():
    num_of_words = int(input("How many words: "))
    query = "SELECT * FROM countries"
    countries = command(query, '', '')
    questions = ['country', 'person(male)', 'person(female)']
    score = 0
    result = []
    for i in range(0, num_of_words):
        entry = countries[randint(0, len(countries) - 1)]
        answers = [entry[1], entry[2], entry[3]]
        correct_ans = dict(zip(questions, answers))
        if multiple_answers(entry,
                            4,
                            5,
                            3,
                            correct_ans,
                            is_noun=True,
                            check_plural=True):
            score += 1

    score_line = f"Score: {score}/{num_of_words}"
    result.append(score == num_of_words)
    result.append(score_line)
    return result
Exemplo n.º 7
0
def load_pronouns():
    query = f"SELECT * FROM subject_pronouns"
    sp_list = list(command(query, '', ''))
    return sp_list