This commit is contained in:
Auric Vente 2024-07-25 05:55:43 -06:00
parent c97c6d0a70
commit d692d8f440
2 changed files with 23 additions and 14 deletions

View File

@ -235,7 +235,14 @@ class Ants:
words = remove(words, ["of", "de", "da", "the"])
if len(words) < 2:
words.extend(Utils.random_word(2 - len(words)))
n = random.randint(1, 2)
if n == 1:
words = Utils.random_words(2 - len(words))
else:
words = Utils.make_words(2 - len(words))
words.extend(words)
return [Utils.capitalize(word) for word in words]

View File

@ -160,17 +160,16 @@ class Utils:
return random.choice(filtered)
@staticmethod
def random_word(num: int = 1) -> list[str]:
words = []
def random_word() -> str:
word = Utils.rand_word.word(
include_parts_of_speech=["nouns", "adjectives"], word_max_length=8
)
for _ in range(num):
word = Utils.rand_word.word(
include_parts_of_speech=["nouns", "adjectives"], word_max_length=8
)
return str(word)
words.append(word)
return words
@staticmethod
def random_words(num: int = 1) -> list[str]:
return [Utils.random_word() for _ in range(num)]
@staticmethod
def capitalize(word: str) -> str:
@ -202,8 +201,11 @@ class Utils:
return name
@staticmethod
def make_name() -> str:
word_1 = Utils.make_word()
word_2 = Utils.make_word()
def make_words(num: int = 1) -> list[str]:
return [Utils.make_word() for _ in range(num)]
return f"{Utils.capitalize(word_1)} {Utils.capitalize(word_2)}"
@staticmethod
def make_name() -> str:
words = Utils.make_words(2)
words = [word.capitalize() for word in words]
return " ".join(words)