From 72368e87b635c4a3a4757e14d590372d9baef05b Mon Sep 17 00:00:00 2001 From: Dazed Date: Sun, 11 Feb 2024 21:02:44 -0600 Subject: [PATCH] Fix mismatch issue in mv --- modules/rpgmakerace.py | 11 ++++++++--- modules/rpgmakermvmz.py | 30 ++++++++++++------------------ modules/tyrano.py | 3 --- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index f2c5ec4..e030ec8 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -260,10 +260,10 @@ def translateNote(event, regex): while i < len(match): oldJAString = match[i] # Remove any textwrap - jaString = re.sub(r'\n', ' ', oldJAString) + oldJAString = oldJAString.replace('\n', ' ') # Translate - response = translateGPT(jaString, 'Reply with only the '+ LANGUAGE +' translation of the RPG Skill name.', False) + response = translateGPT(oldJAString, 'Reply with only the '+ LANGUAGE +' translation.', False) translatedText = response[0] tokens[0] += response[1][0] tokens[1] += response[1][1] @@ -271,7 +271,8 @@ def translateNote(event, regex): # Textwrap translatedText = textwrap.fill(translatedText, width=NOTEWIDTH) translatedText = translatedText.replace('\"', '') - event['note'] = event['note'].replace(oldJAString, translatedText) + jaString = jaString.replace(oldJAString, translatedText) + event['note'] = jaString i += 1 return tokens return [0,0] @@ -572,6 +573,10 @@ def searchNames(data, pbar, context): tokensResponse = translateNote(data[i], r'') totalTokens[0] += tokensResponse[0] totalTokens[1] += tokensResponse[1] + if '<図鑑特徴:' in data[i]['note']: + tokensResponse = translateNote(data[i], r'<図鑑特徴:(.*?)>') + totalTokens[0] += tokensResponse[0] + totalTokens[1] += tokensResponse[1] pbar.update(1) i += 1 else: diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 788bb0d..eaf3ace 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -56,9 +56,9 @@ POSITION = 0 LEAVE = False # Dialogue / Scroll -CODE401 = False -CODE405 = False -CODE408 = False +CODE401 = True +CODE405 = True +CODE408 = True # Choices CODE102 = True @@ -252,10 +252,10 @@ def translateNote(event, regex): while i < len(match): oldJAString = match[i] # Remove any textwrap - jaString = re.sub(r'\n', ' ', oldJAString) + oldJAString = oldJAString.replace('\n', ' ') # Translate - response = translateGPT(jaString, 'Reply with only the '+ LANGUAGE +' translation', False) + response = translateGPT(oldJAString, 'Reply with only the '+ LANGUAGE +' translation.', False) translatedText = response[0] tokens[0] += response[1][0] tokens[1] += response[1][1] @@ -263,7 +263,8 @@ def translateNote(event, regex): # Textwrap translatedText = textwrap.fill(translatedText, width=NOTEWIDTH) translatedText = translatedText.replace('\"', '') - event['note'] = event['note'].replace(oldJAString, translatedText) + jaString = jaString.replace(oldJAString, translatedText) + event['note'] = jaString i += 1 return tokens return [0,0] @@ -2093,7 +2094,7 @@ def subVars(jaString): # Formatting count = 0 - formatList = re.findall(r'[\\]+[\w]*\[[\w\\\[\]]+\]', jaString) + formatList = re.findall(r'[\\]+[\w]*\[[\w\\\[\],\s]+?\]', jaString) formatList = set(formatList) if len(formatList) != 0: for var in formatList: @@ -2164,16 +2165,8 @@ def batchList(input_list, batch_size): def createContext(fullPromptFlag, subbedT): characters = 'Game Characters:\n\ -ファイン (Fine) - Female\n\ -ウェンティ (Wendy) - Female\n\ -クレア (Claire) - Female\n\ -ミナ (Mina) - Female\n\ -サーラ (Sarah) - Female\n\ -ミリェル (Miriel) - Female\n\ -カタリナ (Catalina) - Female\n\ -リリィ (Lily) - Female\n\ -ヴァネット (Vanette) - Female\n\ -セラス (Ceras) - Female\n\ +咲姫 (Saki) - Female\n\ +メアリー (Meary) - Female\n\ ' system = PROMPT + VOCAB if fullPromptFlag else \ @@ -2273,6 +2266,7 @@ def combineList(tlist, text): @retry(exceptions=Exception, tries=5, delay=5) def translateGPT(text, history, fullPromptFlag): + mismatch = False totalTokens = [0, 0] if isinstance(text, list): tList = batchList(text, BATCHSIZE) @@ -2341,4 +2335,4 @@ def translateGPT(text, history, fullPromptFlag): tList[index] = extractedTranslations finalList = combineList(tList, text) - return [finalList, totalTokens] \ No newline at end of file + return [finalList, totalTokens] diff --git a/modules/tyrano.py b/modules/tyrano.py index 5bfdb1b..74a67dc 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -605,9 +605,6 @@ def combineList(tlist, text): @retry(exceptions=Exception, tries=5, delay=5) def translateGPT(text, history, fullPromptFlag): mismatch = False - - if SKIPTRANSLATE: - return [text, [0,0]] totalTokens = [0, 0] if isinstance(text, list): tList = batchList(text, BATCHSIZE)