2016-07-19 15:53:11 +02:00
|
|
|
#!/usr/bin/env python3
|
2016-11-09 09:46:36 +01:00
|
|
|
import yaml
|
2016-07-19 15:53:11 +02:00
|
|
|
import random
|
|
|
|
|
2016-11-09 10:55:17 +01:00
|
|
|
with open('words.yaml') as data_file:
|
2019-04-07 11:13:06 +02:00
|
|
|
data = yaml.safe_load(data_file)
|
2016-11-08 15:00:15 +01:00
|
|
|
|
2016-07-19 15:53:11 +02:00
|
|
|
|
|
|
|
def get_noun():
|
|
|
|
noun = random.choice(data["nouns"])
|
|
|
|
if random.random() <= 0.1:
|
|
|
|
noun += random.choice(data["suffix"])
|
|
|
|
if random.random() <= 0.1:
|
|
|
|
noun = random.choice(data["prefix"]) + noun
|
|
|
|
return noun
|
|
|
|
|
|
|
|
|
2016-11-08 15:00:15 +01:00
|
|
|
def get_description():
|
2016-11-08 16:52:00 +01:00
|
|
|
description = get_noun()
|
2016-11-08 15:00:15 +01:00
|
|
|
mit = False
|
|
|
|
num_extras = round(abs(random.normalvariate(2.0, 2.0)))
|
|
|
|
for i in range(0, num_extras):
|
|
|
|
rand = random.random()
|
|
|
|
if rand <= 0.35:
|
|
|
|
if mit:
|
|
|
|
extra = "und " + get_noun()
|
|
|
|
else:
|
|
|
|
extra = "mit " + get_noun()
|
|
|
|
mit = True
|
|
|
|
elif 0.35 <= rand <= 0.50:
|
|
|
|
extra = "für " + get_noun()
|
|
|
|
elif rand >= 0.90:
|
|
|
|
extra = random.choice(data["digit"])
|
|
|
|
mit = False
|
2016-07-19 15:53:11 +02:00
|
|
|
else:
|
2016-11-08 15:00:15 +01:00
|
|
|
extra = random.choice(data["adj"])
|
|
|
|
mit = False
|
2016-11-08 16:52:00 +01:00
|
|
|
description += " " + extra
|
|
|
|
return description
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
for _ in range(10):
|
|
|
|
print(get_description())
|