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-02 21:27:26 +02:00
|
|
|
def get_names(filename):
|
2024-06-02 21:16:21 +02:00
|
|
|
lines = []
|
2024-06-02 21:27:26 +02:00
|
|
|
with open(filename) as file:
|
2024-06-02 21:16:21 +02:00
|
|
|
lines = file.read().split("\n")
|
|
|
|
names = [
|
|
|
|
name + " "
|
|
|
|
for name in lines
|
2024-06-02 21:27:26 +02:00
|
|
|
if len(name) > 1
|
2024-06-02 21:16:21 +02:00
|
|
|
]
|
|
|
|
return names
|
2024-05-17 19:42:50 +02:00
|
|
|
|
|
|
|
greeting = """
|
|
|
|
Englisch version below.
|
|
|
|
|
|
|
|
Hallo,
|
|
|
|
|
|
|
|
Sie hatten ja um eine Liste der aktuell exmatrikulationsgefährdeten Studierenden gebeten.
|
|
|
|
In der Datenbank sind zwei auf die weiteren Kriterien treffende Studierende zu finden,
|
|
|
|
leider gibt es aber noch einen großen Bestand an nicht korrekt eingepflegten Prüfungsakten,
|
|
|
|
die wir Ihnen zwar digital, aber nicht in einem einheitlichen Format zur Verfügung stellen können.
|
|
|
|
Vielleicht können Sie den ja mit regulären Ausdrücken filtern.
|
|
|
|
|
|
|
|
Viel Spaß
|
|
|
|
|
|
|
|
=== ENGLISCH VERSION ===
|
|
|
|
Hi, we have two students matching the criteria from the database and a certain amount of unstructured data.
|
|
|
|
Maybe you can filter it with regular expressions? Good luck.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# fünf Tatverdächtige
|
|
|
|
# Uhrzeiten, siehe Infos von Verantwortlichen
|
|
|
|
# Groß-Klein-Schreibung
|
|
|
|
|
2024-05-17 20:13:48 +02:00
|
|
|
network = Network(
|
|
|
|
start = Choice(
|
|
|
|
student = ["Student ", "Studentin ", "", "Studierende:r "],
|
|
|
|
),
|
|
|
|
student = Choice(
|
2024-06-02 21:27:26 +02:00
|
|
|
last_name = get_names("vornamen.csv"),
|
2024-05-17 20:17:35 +02:00
|
|
|
matr_nr = [""],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
last_name = Choice(
|
2024-06-02 21:27:26 +02:00
|
|
|
student_mit = get_names("nachnamen.csv"),
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
student_mit = Choice(
|
|
|
|
matr_nr = ["mit "],
|
|
|
|
),
|
|
|
|
matr_nr = Choice(
|
2024-05-17 20:17:35 +02:00
|
|
|
matr_number = ["Matrikelnummer ", "Matrikel-Nummer ", "MatrNr. ", "Matrikel-Nr. "],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
matr_number = RandInt(
|
|
|
|
hat_den = [
|
|
|
|
40_000_000,
|
|
|
|
55_000_000,
|
|
|
|
]
|
|
|
|
),
|
|
|
|
hat_den = FixedText(
|
|
|
|
versuch = "hat den "
|
|
|
|
),
|
|
|
|
versuch = Choice(
|
2024-05-17 20:17:35 +02:00
|
|
|
nicht = ["Erstversuch ", "1. Versuch "],
|
|
|
|
bestanden = ["Zweitversuch ", "2. Versuch "],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
nicht = Choice(
|
|
|
|
bestanden = ["nicht ", ""],
|
|
|
|
),
|
|
|
|
bestanden = FixedText(
|
|
|
|
stop = "bestanden."
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2024-05-17 20:40:29 +02:00
|
|
|
def generate_text(number_of_lines = 100):
|
|
|
|
result = ""
|
|
|
|
for i in range(200):
|
2024-05-17 20:13:48 +02:00
|
|
|
emissions, _ = network.choose()
|
|
|
|
line = ''.join(emissions)
|
2024-05-17 20:40:29 +02:00
|
|
|
result += line + "\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()
|
|
|
|
text = template.replace("<replace with text>", generated)
|
|
|
|
write_index(text)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|