Fix mismatch issue in mv

This commit is contained in:
Dazed 2024-02-11 21:02:44 -06:00
parent bd4898060a
commit 72368e87b6
3 changed files with 20 additions and 24 deletions

View file

@ -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'<SG説明4:(.*?)>')
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:

View file

@ -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]
return [finalList, totalTokens]

View file

@ -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)