Add support for neuter nouns
This commit is contained in:
20
generate.py
20
generate.py
@@ -12,11 +12,18 @@ from reportlab.graphics import renderPDF
|
|||||||
from svglib.svglib import svg2rlg
|
from svglib.svglib import svg2rlg
|
||||||
from urllib.parse import urljoin
|
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
|
random_username = None
|
||||||
while True:
|
while True:
|
||||||
nouns = choice([female_nouns, male_nouns])
|
nouns = choice([female_nouns, male_nouns, neuter_nouns])
|
||||||
random_username = f"{adjectives[randrange(len(adjectives)-1)]}{'' if nouns is female_nouns else 'r'}-{nouns[randrange(len(nouns)-1)].lower()}"
|
|
||||||
|
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:
|
if random_username not in used_usernames:
|
||||||
used_usernames.add(random_username)
|
used_usernames.add(random_username)
|
||||||
print(random_username)
|
print(random_username)
|
||||||
@@ -36,6 +43,7 @@ if __name__ == "__main__":
|
|||||||
adjectives = set()
|
adjectives = set()
|
||||||
female_nouns = set()
|
female_nouns = set()
|
||||||
male_nouns = set()
|
male_nouns = set()
|
||||||
|
neuter_nouns = set()
|
||||||
with open('adjektive-weiblich.txt', 'r') as file:
|
with open('adjektive-weiblich.txt', 'r') as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
adjectives.add(line.strip())
|
adjectives.add(line.strip())
|
||||||
@@ -45,9 +53,13 @@ if __name__ == "__main__":
|
|||||||
with open('nomen-maennlich.txt', 'r') as file:
|
with open('nomen-maennlich.txt', 'r') as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
male_nouns.add(line.strip())
|
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)
|
adjectives = list(adjectives)
|
||||||
female_nouns = list(female_nouns)
|
female_nouns = list(female_nouns)
|
||||||
male_nouns = list(male_nouns)
|
male_nouns = list(male_nouns)
|
||||||
|
neuter_nouns = list(neuter_nouns)
|
||||||
|
|
||||||
pdf = canvas.Canvas(args.output, pagesize=A4)
|
pdf = canvas.Canvas(args.output, pagesize=A4)
|
||||||
page_width, page_height = A4
|
page_width, page_height = A4
|
||||||
@@ -94,7 +106,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
for y in range(codes_per_col):
|
for y in range(codes_per_col):
|
||||||
for x in range(codes_per_row):
|
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)
|
qr_code = QrCodeWidget(url)
|
||||||
bounds = qr_code.getBounds()
|
bounds = qr_code.getBounds()
|
||||||
|
|
||||||
|
|||||||
19
nomen-neutrum.txt
Normal file
19
nomen-neutrum.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Mikrofon
|
||||||
|
Klavier
|
||||||
|
Auge
|
||||||
|
Wort
|
||||||
|
Auto
|
||||||
|
Fahrrad
|
||||||
|
Ohr
|
||||||
|
Lama
|
||||||
|
Brot
|
||||||
|
Feuerwerk
|
||||||
|
Huhn
|
||||||
|
Boot
|
||||||
|
Cello
|
||||||
|
Schlagzeug
|
||||||
|
Herz
|
||||||
|
Geheimnis
|
||||||
|
Pferd
|
||||||
|
Geraet
|
||||||
|
Konzert
|
||||||
Reference in New Issue
Block a user