Removed console log entries, moved script to tools

(cherry picked from commit 8c4ed28fce)
This commit is contained in:
Amatsune 2024-06-28 13:45:07 +02:00 committed by mercurius-00
parent 521c23401b
commit 946aa5ce43
2 changed files with 87 additions and 61 deletions

View File

@ -54,32 +54,19 @@ export function getFusedSpeciesName(speciesA: PokemonSpecies, speciesB: PokemonS
let firstKey = "fusionPrefix"; let firstKey = "fusionPrefix";
let secondKey = "fusionSuffix"; let secondKey = "fusionSuffix";
const shouldReverse = i18next.t("fusionAffixes:shouldReverse");
console.log(`shouldReverse: ${shouldReverse}`); // logs the value of shouldReverse
if (i18next.t("fusionAffixes:shouldReverse") === "true") { if (i18next.t("fusionAffixes:shouldReverse") === "true") {
firstKey = "fusionSuffix"; firstKey = "fusionSuffix";
secondKey = "fusionPrefix"; secondKey = "fusionPrefix";
console.log(`firstKey: ${firstKey}, secondKey: ${secondKey}`); // logs the values of firstKey and secondKey
} }
const radKey = i18next.t(`fusionAffixes:${Species[speciesA.speciesId].toLowerCase()}.${firstKey}`); const radKey = i18next.t(`fusionAffixes:${Species[speciesA.speciesId].toLowerCase()}.${firstKey}`);
const desKey = i18next.t(`fusionAffixes:${Species[speciesB.speciesId].toLowerCase()}.${secondKey}`); const desKey = i18next.t(`fusionAffixes:${Species[speciesB.speciesId].toLowerCase()}.${secondKey}`);
let prefix = radKey; let prefix = radKey;
let suffix = desKey; let suffix = desKey;
if (i18next.t("fusionAffixes:shouldReverse") === "true") { if (i18next.t("fusionAffixes:shouldReverse") === "true") {
prefix = desKey; prefix = desKey;
suffix = radKey; suffix = radKey;
} }
console.log(`prefix: ${prefix}, suffix: ${suffix}`); // logs the values of prefix and suffix
const fusedName =`${prefix}${suffix}`; const fusedName =`${prefix}${suffix}`;
return fusedName; return fusedName;
} }

View File

@ -19,63 +19,101 @@ def is_latin(word):
return False return False
return True return True
#Compare Name Prefixes (to first consonant) #Compare Name Prefixes (to consonant) -> Try to keep shorter than 6ch long
def find_prefixes(word_list): def find_prefixes(pokemon_name):
result = [] result = []
for word in word_list: processed = {} # This dictionary will keep track of the names that have been processed
prefix = "" for word in pokemon_name:
for other_word in word_list: base_word = word # Treat regional variants as separate entries
if word != other_word: if base_word not in processed: # Only process the name if it hasn't been processed before
temp_prefix = "" prefix = ""
for w, o in zip(word, other_word): for other_word in pokemon_name:
if w == o: other_base_word = other_word
temp_prefix += w if base_word != other_base_word:
temp_prefix = ""
for w, o in zip(base_word, other_base_word):
if w == o:
temp_prefix += w
else:
break
if len(temp_prefix) > len(prefix):
prefix = temp_prefix
# Check if the longest shared prefix is the entire species name
if len(prefix) == len(base_word):
processed[base_word] = prefix
else:
# Add the next character in the name to the 'root' of the prefix
root = prefix + base_word[len(prefix)]
# If the root of the prefix ends in a consonant, that should be the result
if root[-1].lower() in "bcdfghjklmnpqrstvwxzçßñ":
processed[base_word] = root
elif len(root) >= 6: # Check if the 'root' is 6 characters or longer
processed[base_word] = root
else: # Try to create an extension to the next consonant
extension = ""
for char in base_word[len(root):]:
extension += char
if char.lower() in "bcdfghjklmnpqrstvwxzçßñ":
break
# Check if the root+extension will be longer than 6 characters
if len(root + extension) > 6:
processed[base_word] = root
else: else:
break processed[base_word] = root + extension
if len(temp_prefix) > len(prefix): result.append(processed[base_word])
prefix = temp_prefix
# Find the first consonant after the prefix
suffix = ""
for i, char in enumerate(word[len(prefix):]):
suffix += char
if char.lower() in "bcdfghjklmnpqrstvwxzçßñ":
# Check if the next character is a hyphen
if i+1 < len(word[len(prefix):]) and word[len(prefix)+i+1] == '-':
suffix += '-'
break
result.append(prefix + suffix)
return result return result
#Compare Name Suffixes (to vowel)
#Compare Name Suffixes (to vowel) -> Try to keep shorter than 6ch long
def find_suffixes(pokemon_name): def find_suffixes(pokemon_name):
result = [] result = []
processed = {} # This dictionary will keep track of the names that have been processed
for word in pokemon_name: for word in pokemon_name:
suffix = "" base_word = word # Treat regional variants as separate entries
for other_word in pokemon_name: if base_word not in processed: # Only process the name if it hasn't been processed before
if word != other_word: suffix = ""
temp_suffix = "" for other_word in pokemon_name:
for w, o in zip(word[::-1], other_word[::-1]): other_base_word = other_word
if w == o: if base_word != other_base_word:
temp_suffix = w + temp_suffix temp_suffix = ""
for w, o in zip(base_word[::-1], other_base_word[::-1]):
if w == o:
temp_suffix = w + temp_suffix
else:
break
if len(temp_suffix) > len(suffix):
suffix = temp_suffix
# Check if the longest shared suffix is the entire species name
if len(suffix) == len(base_word):
processed[base_word] = suffix
else:
# Add the next character in the name to the 'root' of the suffix
root = base_word[len(base_word) - len(suffix) - 1] + suffix
# If the root of the suffix ends in a vowel, that should be the result
if root[0].lower() in "aeiouyáééíóúàèìòùâêîôûäëïöüãẽĩõũæœøýỳÿŷỹ":
processed[base_word] = root
elif len(root) >= 6: # Check if the 'root' is 6 characters or longer
processed[base_word] = root
else: # Try to create an extension to the next vowel
extension = ""
for char in base_word[len(base_word) - len(root) - 1::-1]:
extension = char + extension
if char.lower() in "aeiouyáééíóúàèìòùâêîôûäëïöüãẽĩõũæœøýỳÿŷỹ":
break
# Check if the root+extension will be longer than 6 characters
if len(extension + root) > 6:
processed[base_word] = root
else: else:
break processed[base_word] = extension + root
if len(temp_suffix) > len(suffix): # Ensure the first character of the suffix is a lowercase letter
suffix = temp_suffix processed[base_word] = processed[base_word][0].lower() + processed[base_word][1:]
# Find the first vowel before the suffix # Check if the character before the suffix is a hyphen
prefix = "" if len(base_word) > len(processed[base_word]) and base_word[len(base_word) - len(processed[base_word]) - 2] == '-':
for i, char in enumerate(word[len(word)-len(suffix)-1::-1]): processed[base_word] = '-' + processed[base_word]
prefix = char + prefix result.append(processed[base_word])
if char.lower() in "aeiouyáééíóúàèìòùâêîôûäëïöüãẽĩõũæœøýỳÿŷỹ":
# Check if the next character is a hyphen
if i+1 < len(word) and word[len(word)-len(suffix)-i-2] == '-':
prefix = '-' + prefix
break
# Make sure the first character is lowercase
output = (prefix + suffix)
output = output[0].lower() + output[1:]
result.append(output)
return result return result
def generate_pokemon(file_path): def generate_pokemon(file_path):
with open(file_path, 'r', encoding='utf-8') as file: # Specify the encoding here with open(file_path, 'r', encoding='utf-8') as file: # Specify the encoding here
lines = file.readlines() lines = file.readlines()
@ -101,7 +139,7 @@ def combine_scripts(file_path):
output = "import { FusionTranslationEntries } from \"#app/interfaces/locales\";\n\n" output = "import { FusionTranslationEntries } from \"#app/interfaces/locales\";\n\n"
output += "export const fusionAffixes: FusionTranslationEntries = {\n" output += "export const fusionAffixes: FusionTranslationEntries = {\n"
output += " shouldReverse: \"true\",\n" output += " shouldReverse: \"false\",\n"
for word, prefix, suffix in zip(pokemon_dict.keys(), prefixes, suffixes): for word, prefix, suffix in zip(pokemon_dict.keys(), prefixes, suffixes):
output += f" {word}: {{\n" output += f" {word}: {{\n"
@ -123,6 +161,7 @@ file_path = r"pokemon.ts"
# Call the combined function # Call the combined function
combine_scripts(file_path) combine_scripts(file_path)
#universal-fusion-affixes-generator #universal-fusion-affixes-generator
""""import re """"import re