summaryrefslogtreecommitdiffstats
path: root/kasus.py
blob: 57ebc4a61bdcd7c47bf57ee8853309ea419b687e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from colorama import Fore, Back, Style
import readline

import solver

total = 0
correct = 0

while True:
    query, solution = solver.get()

    parameters = f"{Fore.MAGENTA}{query.case}, {Fore.BLUE}{query.article}, {Fore.YELLOW}{query.cardinality}{Style.RESET_ALL}"
    queryString = f"{query.noun['nom-sin']}, {query.adjective}"

    total += 1
    print(f"{Style.BRIGHT}--- Übung {total} ---{Style.NORMAL}")
    print(parameters)
    print()
    print(queryString)
    print()

    try:
        response = input("> ")
    except (KeyboardInterrupt, EOFError):
        # TODO print statistics
        print("\nBis später!")
        break

    print(f"{Style.BRIGHT}", end="")

    if solution.evaluate(response):
        correct += 1
        print(f"{Fore.GREEN}Richtig ({correct}/{total}):{Style.RESET_ALL} {solution.noun}")
    else:
        print(f"{Fore.RED}Falsch ({correct}/{total}):{Style.RESET_ALL} {solution.full}, {solution.noun}")