auto name gen

This commit is contained in:
2026-06-24 16:52:55 -04:00
parent 54b0c5cb8c
commit 144625cb5b
7 changed files with 14595 additions and 10 deletions

14394
untitled/assets/nameset.csv Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -32,3 +32,41 @@ CAT_PERSONALITIES = [ # TODO: start at different happiness levels based on pers
"just wants to be somewhere else",
]
CAT_EYE_COLORS = ["green", "yellow", "blue", "orange"]
NAME_ONSETS = [
"b",
"br",
"tr",
"m",
"p",
"k",
"s",
"sk",
"wh",
"fl",
"n",
"j",
"d",
"g",
"ch",
"th",
]
NAME_VOWELS = ["a", "e", "i", "o", "u", "oo", "ee", "ai"]
NAME_CODAS = [
"",
"",
"",
"",
"",
"",
"",
"",
"n",
"x",
"ff",
"sk",
"t",
"p",
"ll",
] # empty entries = "often no coda"

View File

@@ -1,6 +1,8 @@
import csv
import random
from collections import defaultdict
from untitled import content
from untitled import content, rules
def generate_trait_sentence(traits):
@@ -26,3 +28,67 @@ def generate_cat_choice(personality=None):
def generate_cat_choices(n=5):
personalities = random.sample(content.CAT_PERSONALITIES, n)
return [generate_cat_choice(p) for p in personalities]
# NAME GEN MODEL
def _pad_names_for_model(names):
new_names = []
for name in names:
new_names.append(f"<<{name}>")
return new_names
def _build_model(words):
model = defaultdict(list)
for word in words:
for pos in range(len(word) - 2):
model[word[pos] + word[pos + 1]].append(word[pos + 2])
return model
def _make_name(model):
result = "<<"
while True:
window = result[-2:]
nxt = random.choice(model[window])
if nxt == ">":
break
result += nxt
return result.removeprefix("<<")
def generate_name():
while True:
name = _make_name(_model)
if (
any(c in "aeiou" for c in name.lower())
and len(name) <= 9
and rules.validate_cat_name(name) is None
):
return name.capitalize()
def _load_raw_names():
names = []
with open("untitled/assets/nameset.csv", newline="", encoding="utf-8") as file:
reader = csv.reader(file)
next(reader)
for row in reader:
name = row[5].lower()
if (
name == "name not provided"
or name == "untitled"
or name == "unknown"
or name == "kitten"
or not name
):
continue
if name.isalpha():
names.append(name)
return names
_model = _build_model(_pad_names_for_model(_load_raw_names()))

View File

@@ -3,8 +3,8 @@ from untitled import generation, model, rules, ui
def adoption():
print("Welcome to the shelter!")
while True:
auto_name = ""
choice = "Reroll"
while choice == "Reroll":
choices = generation.generate_cat_choices()
@@ -14,11 +14,19 @@ def adoption():
)
while True:
name = ui.text("Please choose a name for your cat:")
error = rules.validate_cat_name(name)
if not error:
break
print(error)
name = ui.text(
'Please choose a name for your cat or type "idk" to autofill a generated one:',
auto_name,
)
if name.lower() != "idk":
auto_name = ""
error = rules.validate_cat_name(name)
if not error:
break
print(error)
else:
auto_name = generation.generate_name()
if ui.confirm(
f"Do you want to adopt {name}, {generation.generate_trait_sentence(choice).lower()}?"
):

View File

@@ -40,8 +40,8 @@ def select(title, options):
return questionary.select(title, options).ask()
def text(title):
return questionary.text(title).ask()
def text(title, default):
return questionary.text(title, default=default).ask()
def confirm(title):