2024-05-17 19:42:50 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
from random import randint, random, choice
|
|
|
|
|
2024-06-02 21:10:30 +02:00
|
|
|
from choice_network import Choice, FixedText, RandInt, Network
|
|
|
|
|
2024-06-03 13:35:05 +02:00
|
|
|
def get_names(filename, pad = " "):
|
2024-06-03 10:39:40 +02:00
|
|
|
lines = []
|
|
|
|
with open(filename) as file:
|
|
|
|
lines = file.read().split("\n")
|
|
|
|
names = [
|
2024-06-03 13:35:05 +02:00
|
|
|
name + pad
|
2024-06-03 10:39:40 +02:00
|
|
|
for name in lines
|
|
|
|
if len(name) > 1
|
|
|
|
]
|
|
|
|
return names
|
2024-05-17 19:42:50 +02:00
|
|
|
|
2024-06-05 12:14:19 +02:00
|
|
|
greeting = {"": """
|
2024-06-03 14:17:41 +02:00
|
|
|
Re: AW: Studierendenabfrage
|
|
|
|
von: Prüfungsverwaltung
|
2024-06-03 10:39:53 +02:00
|
|
|
---------
|
2024-06-05 12:22:41 +02:00
|
|
|
English-only version at cc.ifsr.de/en, this page is bilingual.
|
|
|
|
Eine nur auf deutsch formulierte Variante ist unter cc.ifsr.de/de
|
2024-05-17 19:42:50 +02:00
|
|
|
|
|
|
|
Hallo,
|
|
|
|
|
2024-06-03 12:45:40 +02:00
|
|
|
Zur angefragten Prüfung gibt es leider noch keine Datenbank,
|
2024-06-03 14:17:41 +02:00
|
|
|
daher unten angefügt unsere Notizen aus Prüfungsakten und Personendatenbank,
|
|
|
|
immer mit automatisch erstellter englischer Überstzung.
|
2024-06-03 12:45:40 +02:00
|
|
|
Vielleicht können Sie die ja mit regulären Ausdrücken filtern.
|
|
|
|
Das funktioniert wie normale Text-Suche, nur etwas flexibler:
|
|
|
|
(Erst|Zweit)versuch z.B. würde sowohl 'Erstversuch'
|
|
|
|
als auch 'Zweitversuch' markieren.
|
2024-06-05 12:48:01 +02:00
|
|
|
.* akzeptiert alle Zeichen, das können Sie an die 'Expression'
|
2024-06-03 14:17:41 +02:00
|
|
|
(oben auf der Seite) vorn anfügen,
|
2024-06-03 13:27:57 +02:00
|
|
|
um im Menü 'List' unten rechts den Anfang der Zeile zu sehen.
|
2024-06-03 14:17:41 +02:00
|
|
|
Sie sollten etwa 5 Studierende finden.
|
2024-05-17 19:42:50 +02:00
|
|
|
|
|
|
|
Viel Spaß
|
|
|
|
|
|
|
|
=== ENGLISCH VERSION ===
|
2024-06-03 12:45:40 +02:00
|
|
|
Hi,
|
2024-06-05 12:14:19 +02:00
|
|
|
|
2024-06-03 14:17:41 +02:00
|
|
|
there is no database for this exam, so I added our digitized notes below,
|
2024-06-05 11:56:59 +02:00
|
|
|
always with the auto-generated english translation.
|
2024-06-03 12:45:40 +02:00
|
|
|
Maybe you can filter it with regular expressions?
|
2024-06-03 13:02:12 +02:00
|
|
|
They are like normal text-search but more flexible:
|
2024-06-03 12:45:40 +02:00
|
|
|
E.g.: (Erst|Zweit)versuch would select both words:
|
|
|
|
'Erstversuch' (first attempt) and 'Zweitversuch' (second attempt).
|
2024-06-05 12:48:01 +02:00
|
|
|
.* will accept any text, you can add it at the start of the expression
|
2024-06-05 12:14:19 +02:00
|
|
|
(top of page) to see the whole line in the menu 'List' (bottom right).
|
|
|
|
You should find approximately 5 students.
|
|
|
|
|
|
|
|
Good Luck
|
|
|
|
""", "de": """
|
|
|
|
Re: AW: Studierendenabfrage
|
|
|
|
von: Prüfungsverwaltung
|
|
|
|
---------
|
|
|
|
|
|
|
|
Hallo,
|
|
|
|
|
|
|
|
Zur angefragten Prüfung gibt es leider noch keine Datenbank,
|
|
|
|
daher unten angefügt unsere Notizen aus Prüfungsakten und Personendatenbank.
|
|
|
|
Vielleicht können Sie die ja mit regulären Ausdrücken filtern.
|
|
|
|
Das funktioniert wie normale Text-Suche, nur etwas flexibler:
|
|
|
|
(Erst|Zweit)versuch z.B. würde sowohl 'Erstversuch'
|
|
|
|
als auch 'Zweitversuch' markieren.
|
2024-06-05 12:48:01 +02:00
|
|
|
.* akzeptiert alle Zeichen, das können Sie an die 'Expression'
|
2024-06-05 12:14:19 +02:00
|
|
|
(oben auf der Seite) vorn anfügen,
|
|
|
|
um im Menü 'List' unten rechts den Anfang der Zeile zu sehen.
|
|
|
|
Sie sollten etwa 5 Studierende finden.
|
|
|
|
|
|
|
|
Viel Spaß
|
|
|
|
|
|
|
|
""", "en": """
|
|
|
|
Re: AW: Student data request
|
2024-06-05 12:49:32 +02:00
|
|
|
from: Exam management
|
2024-06-05 12:14:19 +02:00
|
|
|
---------
|
|
|
|
|
|
|
|
Hi,
|
|
|
|
|
|
|
|
there is no database for this exam, so I added our digitized notes below .
|
|
|
|
Maybe you can filter it with regular expressions?
|
|
|
|
They are like normal text-search but more flexible:
|
2024-06-05 12:19:38 +02:00
|
|
|
E.g.: /(first|second) attempt/ would select both:
|
|
|
|
'first attempt' and 'second attempt'.
|
2024-06-05 12:48:01 +02:00
|
|
|
.* will accept any text, you can add it at the start of the expression
|
2024-06-05 12:14:19 +02:00
|
|
|
(top of page) to see the whole line in the menu 'List' (bottom right).
|
2024-06-03 14:17:41 +02:00
|
|
|
You should find approximately 5 students.
|
|
|
|
|
|
|
|
Good Luck
|
2024-06-05 12:14:19 +02:00
|
|
|
"""}
|
2024-05-17 19:42:50 +02:00
|
|
|
|
|
|
|
# fünf Tatverdächtige
|
|
|
|
# Uhrzeiten, siehe Infos von Verantwortlichen
|
|
|
|
# Groß-Klein-Schreibung
|
2024-06-03 11:41:53 +02:00
|
|
|
date = "05.06.2024"
|
2024-06-03 11:02:01 +02:00
|
|
|
hidden_data = [
|
2024-06-03 13:55:37 +02:00
|
|
|
"Anna Bartel: Zweitversuch nicht bestanden.\n"
|
|
|
|
"Anna Bartel: second attempt not passed.",
|
|
|
|
"Boris Parsch: Zweitversuch nicht bestanden.\n"
|
|
|
|
"Boris Parsch: second attempt not passed.",
|
2024-06-03 14:43:34 +02:00
|
|
|
"Charlotte Winter: 2. Versuch nicht bestanden.\n"
|
|
|
|
"Charlotte Winter: 2nd attempt not passed.",
|
2024-06-03 13:55:37 +02:00
|
|
|
"Dennis Meier: 2. Versuch nicht bestanden.\n"
|
|
|
|
"Dennis Meier: 2nd attempt not passed.",
|
|
|
|
"Elisa Menniz: Zweitversuch nicht bestanden.\n"
|
|
|
|
"Elisa Menniz: second attempt not passed.",
|
|
|
|
f"Anna Bartel: Prüfung am {date} um 13:00.\n"
|
|
|
|
f"Anna Bartel: exam on {date}, 13:00.",
|
|
|
|
f"Boris Parsch: Prüfung am {date} um 14:00.\n"
|
|
|
|
f"Boris Parsch: exam on {date}, 14:00.",
|
2024-06-03 14:43:34 +02:00
|
|
|
f"Charlotte Winter: Prüfung am {date} um 13:30.\n"
|
|
|
|
f"Charlotte Winter: exam on {date}, 13:30.",
|
2024-06-03 13:55:37 +02:00
|
|
|
f"Dennis Meier: Prüfung am {date} um 10:00.\n"
|
|
|
|
f"Dennis Meier: exam on {date}, 10:00.",
|
|
|
|
f"Elisa Menniz: Prüfung am {date} um 14:30.\n"
|
|
|
|
f"Elisa Menniz: exam on {date}, 14:30.",
|
|
|
|
f"Anna Bartel: blaue Augen.\n"
|
|
|
|
f"Anna Bartel: blue eyes.",
|
|
|
|
f"Boris Parsch: blaue Augen.\n"
|
|
|
|
f"Boris Parsch: blue eyes.",
|
2024-06-03 14:43:34 +02:00
|
|
|
f"Charlotte Winter: blaue Augen.\n"
|
|
|
|
f"Charlotte Winter: blue eyes.",
|
2024-06-03 13:55:37 +02:00
|
|
|
f"Dennis Meier: grüne Augen.\n"
|
|
|
|
f"Dennis Meier: green eyes.",
|
|
|
|
f"Elisa Menniz: grüne Augen.\n"
|
|
|
|
f"Elisa Menniz: green eyes.",
|
2024-06-03 11:02:01 +02:00
|
|
|
]
|
2024-05-17 19:42:50 +02:00
|
|
|
|
2024-05-17 20:13:48 +02:00
|
|
|
network = Network(
|
|
|
|
start = Choice(
|
2024-06-03 12:10:45 +02:00
|
|
|
student = [""],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
student = Choice(
|
2024-06-02 21:27:26 +02:00
|
|
|
last_name = get_names("vornamen.csv"),
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
last_name = Choice(
|
2024-06-03 13:35:05 +02:00
|
|
|
student_mit = get_names("nachnamen.csv", pad = ""),
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
student_mit = Choice(
|
2024-06-03 12:17:12 +02:00
|
|
|
hat_den = [""],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
2024-06-03 11:12:40 +02:00
|
|
|
hat_den = Choice(
|
2024-06-03 13:35:05 +02:00
|
|
|
versuch = [": ",],
|
2024-06-03 13:42:37 +02:00
|
|
|
prüfungszeit = [(f": Prüfung am {date} um ", f": exam on {date}, ")],
|
2024-06-03 13:35:05 +02:00
|
|
|
augenfarbe = [": ",],
|
2024-06-03 12:00:14 +02:00
|
|
|
),
|
|
|
|
augenfarbe = Choice(
|
2024-06-03 13:42:37 +02:00
|
|
|
augen = [
|
|
|
|
("grüne ", "green "),
|
|
|
|
("braune ", "brown "),
|
|
|
|
("blaue ", "blue "),
|
|
|
|
],
|
2024-06-03 12:00:14 +02:00
|
|
|
),
|
|
|
|
augen = FixedText(
|
2024-06-03 13:42:37 +02:00
|
|
|
stop = ("Augen.", "eyes."),
|
2024-06-03 11:12:40 +02:00
|
|
|
),
|
|
|
|
prüfungszeit = Choice(
|
|
|
|
uhr = [
|
|
|
|
"09:00",
|
|
|
|
"09:30",
|
|
|
|
"10:00",
|
|
|
|
"10:30",
|
|
|
|
"11:00",
|
|
|
|
"11:30",
|
|
|
|
"12:00",
|
|
|
|
"12:30",
|
|
|
|
"13:00",
|
|
|
|
"13:30",
|
|
|
|
"14:00",
|
|
|
|
"14:30",
|
|
|
|
"15:00",
|
|
|
|
"15:30",
|
|
|
|
],
|
|
|
|
),
|
|
|
|
uhr = FixedText(
|
2024-06-03 13:42:37 +02:00
|
|
|
stop = (" Uhr.", "."),
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
versuch = Choice(
|
2024-06-03 13:42:37 +02:00
|
|
|
nicht = [
|
2024-06-03 13:55:37 +02:00
|
|
|
("Erstversuch ", "first attempt "),
|
|
|
|
("1. Versuch ", "1st attempt "),
|
2024-06-03 13:42:37 +02:00
|
|
|
],
|
|
|
|
bestanden = [
|
2024-06-03 13:55:37 +02:00
|
|
|
("Erstversuch ", "first attempt "),
|
|
|
|
("1. Versuch ", "1st attempt "),
|
|
|
|
("Zweitversuch ", "second attempt "),
|
|
|
|
("2. Versuch ", "2nd attempt "),
|
2024-06-03 13:42:37 +02:00
|
|
|
],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
nicht = Choice(
|
2024-06-03 13:42:37 +02:00
|
|
|
bestanden = [
|
|
|
|
("nicht ", "not "),
|
|
|
|
""
|
|
|
|
],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
bestanden = FixedText(
|
2024-06-03 13:42:37 +02:00
|
|
|
stop = ("bestanden.", "passed."),
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2024-06-05 12:09:19 +02:00
|
|
|
def generate_text(number_of_lines = 200, language = None):
|
|
|
|
""" language can be None (both), "en" or "de".
|
|
|
|
"""
|
2024-06-05 12:47:02 +02:00
|
|
|
local_hidden_data = hidden_data[:]
|
2024-06-05 12:09:19 +02:00
|
|
|
do_german = not language or language == "de"
|
|
|
|
do_english = not language or language == "en"
|
2024-05-17 20:40:29 +02:00
|
|
|
result = ""
|
2024-06-03 11:02:01 +02:00
|
|
|
for i in range(number_of_lines):
|
2024-05-17 20:13:48 +02:00
|
|
|
emissions, _ = network.choose()
|
2024-06-03 13:55:37 +02:00
|
|
|
german = ""
|
|
|
|
english = ""
|
|
|
|
for emission in emissions:
|
|
|
|
match emission:
|
|
|
|
case (ger, eng):
|
|
|
|
german += ger
|
|
|
|
english += eng
|
|
|
|
case both:
|
|
|
|
german += both
|
|
|
|
english += both
|
2024-06-05 12:09:19 +02:00
|
|
|
if do_german: result += german + "\n"
|
|
|
|
if do_english: result += english + "\n"
|
2024-06-05 12:47:02 +02:00
|
|
|
if random() < len(local_hidden_data) / (number_of_lines - i):
|
|
|
|
index = randint(0, len(local_hidden_data) - 1)
|
|
|
|
hidden_line = local_hidden_data.pop(index)
|
2024-06-05 12:09:19 +02:00
|
|
|
german, english = hidden_line.split("\n")
|
|
|
|
if do_german: result += german + "\n"
|
|
|
|
if do_english: result += english + "\n"
|
2024-05-17 20:40:29 +02:00
|
|
|
return result
|
|
|
|
|
|
|
|
def read_template(filename = "./template.html"):
|
|
|
|
with open(filename, "r") as file:
|
|
|
|
return file.read()
|
|
|
|
|
|
|
|
def write_index(text, filename = "./deploy/index.html"):
|
|
|
|
with open(filename, "w") as file:
|
|
|
|
file.write(text)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
template = read_template()
|
2024-06-05 12:38:35 +02:00
|
|
|
for language in ["de", "en"]:
|
2024-06-05 12:09:19 +02:00
|
|
|
generated = generate_text(language = language)
|
2024-06-05 12:14:19 +02:00
|
|
|
generated = greeting[language] + "\n" + generated
|
2024-06-05 12:09:19 +02:00
|
|
|
text = template.replace("<replace with text>", generated)
|
|
|
|
write_index(text, filename = f"./deploy/{language}/index.html")
|
2024-05-17 20:40:29 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|