-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathname_generation.py
More file actions
96 lines (82 loc) · 2.01 KB
/
name_generation.py
File metadata and controls
96 lines (82 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import random
from typing import List, TypeVar
def one_of_in_x_times(choices: List[str], times: int) -> List[str]:
return choices + ([""] * (times - 1) * len(choices))
T = TypeVar("T")
def choose(choices: List[T]) -> T:
return choices[random.randint(0, len(choices) - 1)]
class FoodNamer:
name_part_ones = [
"spotted",
"toad",
"toddy",
"beef",
"clotted",
"bangers",
"ham",
"fish",
"fried",
"jellied",
"black",
"ploughman's",
"stottie",
"eccles",
"eaton",
"shepherd's",
"knickerbocker",
"angel",
"lardy",
"jam",
"bubble",
"stargazy",
"boiled",
"lancashire",
"devonshire",
"roast",
"pickled",
"soused",
]
name_part_twos = [
"hole",
"pie",
"wellington",
"mash",
"tiddly",
"eels",
"pudding",
"stottie",
"pasty",
"tart",
"crumble",
"dick",
"glory",
"delight",
"cake",
"rolly polly",
"scratchings",
"squeak",
"roast",
]
joining_words = one_of_in_x_times(["in the", "and", "cream"], times=3)
suffix = one_of_in_x_times(
[
"in gravy",
"with gravy",
"with chips",
"with mint sauce",
"with custard",
"in blankets",
],
times=4,
)
# Items which are either boring or rude should be excluded
banned_list = ["spotted dick", "fish pie"]
def generate_food_name(self) -> str:
result = None
while result in self.banned_list or result is None:
result = _tidy_name(
f"{choose(self.name_part_ones)} {choose(self.joining_words)} {choose(self.name_part_twos)} {choose(self.suffix)}"
)
return result
def _tidy_name(food_name: str) -> str:
return food_name.strip().replace(" ", " ")