Add support for neuter nouns

This commit is contained in:
2026-01-13 15:49:43 +01:00
parent 644f539641
commit 548c9d8d9b
2 changed files with 35 additions and 4 deletions

View File

@@ -12,11 +12,18 @@ from reportlab.graphics import renderPDF
from svglib.svglib import svg2rlg
from urllib.parse import urljoin
def generate_random_username(female_nouns, male_nouns, adjectives, used_usernames):
def generate_random_username(female_nouns, male_nouns, neuter_nouns, adjectives, used_usernames):
random_username = None
while True:
nouns = choice([female_nouns, male_nouns])
random_username = f"{adjectives[randrange(len(adjectives)-1)]}{'' if nouns is female_nouns else 'r'}-{nouns[randrange(len(nouns)-1)].lower()}"
nouns = choice([female_nouns, male_nouns, neuter_nouns])
adjektive_suffix = ""
if nouns is male_nouns:
adjektive_suffix = "r"
elif nouns is neuter_nouns:
adjektive_suffix = "s"
random_username = f"{adjectives[randrange(len(adjectives))]}{adjektive_suffix}-{nouns[randrange(len(nouns))].lower()}"
if random_username not in used_usernames:
used_usernames.add(random_username)
print(random_username)
@@ -36,6 +43,7 @@ if __name__ == "__main__":
adjectives = set()
female_nouns = set()
male_nouns = set()
neuter_nouns = set()
with open('adjektive-weiblich.txt', 'r') as file:
for line in file:
adjectives.add(line.strip())
@@ -45,9 +53,13 @@ if __name__ == "__main__":
with open('nomen-maennlich.txt', 'r') as file:
for line in file:
male_nouns.add(line.strip())
with open('nomen-neutrum.txt', 'r') as file:
for line in file:
neuter_nouns.add(line.strip())
adjectives = list(adjectives)
female_nouns = list(female_nouns)
male_nouns = list(male_nouns)
neuter_nouns = list(neuter_nouns)
pdf = canvas.Canvas(args.output, pagesize=A4)
page_width, page_height = A4
@@ -94,7 +106,7 @@ if __name__ == "__main__":
for y in range(codes_per_col):
for x in range(codes_per_row):
url = urljoin(args.url, generate_random_username(female_nouns, male_nouns, adjectives, used_usernames))
url = urljoin(args.url, generate_random_username(female_nouns, male_nouns, neuter_nouns, adjectives, used_usernames))
qr_code = QrCodeWidget(url)
bounds = qr_code.getBounds()

19
nomen-neutrum.txt Normal file
View File

@@ -0,0 +1,19 @@
Mikrofon
Klavier
Auge
Wort
Auto
Fahrrad
Ohr
Lama
Brot
Feuerwerk
Huhn
Boot
Cello
Schlagzeug
Herz
Geheimnis
Pferd
Geraet
Konzert