192 lines
4.6 KiB
Python
Executable file
192 lines
4.6 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
from random import randint, random, choice
|
|
|
|
from choice_network import Choice, FixedText, RandInt, Network
|
|
|
|
def get_names(filename):
|
|
lines = []
|
|
with open(filename) as file:
|
|
lines = file.read().split("\n")
|
|
names = [
|
|
name + " "
|
|
for name in lines
|
|
if len(name) > 1
|
|
]
|
|
return names
|
|
|
|
greeting = """
|
|
Re: AW: Exmatrikulationsgefährdete Studierende
|
|
---------
|
|
Englisch version below.
|
|
|
|
Hallo,
|
|
|
|
Zur angefragten Prüfung gibt es leider noch keine Datenbank,
|
|
daher hier 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.
|
|
.+ akzeptiert alle Zeichen, das können Sie vorn anfügen,
|
|
um im unteren Menü 'List' den Anfang der Zeile zu sehen.
|
|
|
|
Viel Spaß
|
|
|
|
=== ENGLISCH VERSION ===
|
|
Hi,
|
|
there is no database for this exam, so we can only send our digitized notes.
|
|
Maybe you can filter it with regular expressions?
|
|
They are like normal text-search but more flexible:
|
|
E.g.: (Erst|Zweit)versuch would select both words:
|
|
'Erstversuch' (first attempt) and 'Zweitversuch' (second attempt).
|
|
.+ will accept any text, you can add it at the start to see the whole line
|
|
in the lower menu 'List'.
|
|
"""
|
|
|
|
# fünf Tatverdächtige
|
|
# Uhrzeiten, siehe Infos von Verantwortlichen
|
|
# Groß-Klein-Schreibung
|
|
date = "05.06.2024"
|
|
hidden_data = [
|
|
"Anna Bartel hat den Zweitversuch nicht bestanden.",
|
|
"Boris Parsch hat den Zweitversuch nicht bestanden.",
|
|
"Carola Winter hat den 2. Versuch nicht bestanden.",
|
|
"Dennis Meier hat den 2. Versuch nicht bestanden.",
|
|
"Elisa Menniz hat den Zweitversuch nicht bestanden.",
|
|
f"Anna Bartel hat die Prüfung am {date} um 13:00.",
|
|
f"Boris Parsch hat die Prüfung am {date} um 14:00.",
|
|
f"Carola Winter hat die Prüfung am {date} um 13:30.",
|
|
f"Dennis Meier hat die Prüfung am {date} um 10:00.",
|
|
f"Elisa Menniz hat die Prüfung am {date} um 14:30.",
|
|
f"Anna Bartel hat blaue Augen.",
|
|
f"Boris Parsch hat blaue Augen.",
|
|
f"Carola Winter hat blaue Augen.",
|
|
f"Dennis Meier hat grüne Augen.",
|
|
f"Elisa Menniz hat grüne Augen.",
|
|
]
|
|
|
|
network = Network(
|
|
start = Choice(
|
|
#student_mit = ["Student ", "Studentin ", "Studierende:r "],
|
|
student = [""],
|
|
),
|
|
student = Choice(
|
|
last_name = get_names("vornamen.csv"),
|
|
),
|
|
last_name = Choice(
|
|
student_mit = get_names("nachnamen.csv"),
|
|
),
|
|
student_mit = Choice(
|
|
#matr_nr = ["mit "],
|
|
hat_den = [""],
|
|
),
|
|
matr_nr = Choice(
|
|
matr_number = ["Matrikelnummer ", "Matrikel-Nummer ", "MatrNr. ", "Matrikel-Nr. "],
|
|
),
|
|
matr_number = RandInt(
|
|
hat_den = [
|
|
40_000_000,
|
|
55_000_000,
|
|
],
|
|
),
|
|
hat_den = Choice(
|
|
versuch = ["hat den ",],
|
|
prüfungszeit = [f"hat die Prüfung am {date} um ",],
|
|
augenfarbe = ["hat ",],
|
|
),
|
|
augenfarbe = Choice(
|
|
augen = ["grüne ", "braune ", "blaue ",],
|
|
),
|
|
augen = FixedText(
|
|
stop = "Augen.",
|
|
#körpergröße = "Augen und ist ",
|
|
),
|
|
körpergröße = RandInt(
|
|
cm_groß = [
|
|
150,
|
|
200,
|
|
],
|
|
),
|
|
cm_groß = FixedText(
|
|
stop = "cm groß.",
|
|
),
|
|
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(
|
|
stop = " Uhr.",
|
|
),
|
|
prüfungsart = Choice( #inactive
|
|
prüfung = ["schriftliche ", "mündliche "],
|
|
),
|
|
prüfung = FixedText( #inactive
|
|
stop = "Prüfung.",
|
|
),
|
|
prüfungsname = Choice( #inactive
|
|
prüfungsname_end = get_names("chemie.csv"),
|
|
),
|
|
prüfungsname_end = FixedText( #incative
|
|
stop = "'.",
|
|
),
|
|
versuch = Choice(
|
|
nicht = ["Erstversuch ", "1. Versuch "],
|
|
bestanden = ["Erstversuch ", "1. Versuch ", "Zweitversuch ", "2. Versuch "],
|
|
),
|
|
nicht = Choice(
|
|
bestanden = ["nicht ", ""],
|
|
),
|
|
bestanden = FixedText(
|
|
stop = "bestanden.",
|
|
),
|
|
)
|
|
|
|
def pop_hidden_data():
|
|
global hidden_data
|
|
index = randint(0, len(hidden_data) - 1)
|
|
return hidden_data.pop(index)
|
|
|
|
def generate_text(number_of_lines = 200):
|
|
result = ""
|
|
for i in range(number_of_lines):
|
|
emissions, _ = network.choose()
|
|
line = ''.join(emissions)
|
|
result += line + "\n"
|
|
if random() < len(hidden_data) / (number_of_lines - i):
|
|
result += pop_hidden_data() + "\n"
|
|
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()
|
|
generated = generate_text()
|
|
generated = greeting + "\n" + generated
|
|
text = template.replace("<replace with text>", generated)
|
|
write_index(text)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|