Slightly edit 102
This commit is contained in:
parent
5f14fe0703
commit
c149f0d22c
2 changed files with 36 additions and 37 deletions
|
|
@ -61,13 +61,13 @@ LEAVE = False
|
||||||
# Dialogue / Scroll
|
# Dialogue / Scroll
|
||||||
CODE401 = False
|
CODE401 = False
|
||||||
CODE405 = False
|
CODE405 = False
|
||||||
CODE408 = True
|
CODE408 = False
|
||||||
|
|
||||||
# Choices
|
# Choices
|
||||||
CODE102 = False
|
CODE102 = False
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
CODE122 = False
|
CODE122 = True
|
||||||
|
|
||||||
# Names
|
# Names
|
||||||
CODE101 = False
|
CODE101 = False
|
||||||
|
|
@ -1080,7 +1080,7 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
## Event Code: 122 [Set Variables]
|
## Event Code: 122 [Set Variables]
|
||||||
if codeList[i]['c'] == 122 and CODE122 is True:
|
if codeList[i]['c'] == 122 and CODE122 is True:
|
||||||
# This is going to be the var being set. (IMPORTANT)
|
# This is going to be the var being set. (IMPORTANT)
|
||||||
if codeList[i]['p'][0] not in [315,316,317,318,319,320,321,322,323,324,325]:
|
if codeList[i]['p'][0] not in [528, 944]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
jaString = codeList[i]['p'][4]
|
jaString = codeList[i]['p'][4]
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,9 @@ POSITION = 0
|
||||||
LEAVE = False
|
LEAVE = False
|
||||||
|
|
||||||
# Dialogue / Scroll
|
# Dialogue / Scroll
|
||||||
CODE401 = True
|
CODE401 = False
|
||||||
CODE405 = True
|
CODE405 = False
|
||||||
CODE408 = True
|
CODE408 = False
|
||||||
|
|
||||||
# Choices
|
# Choices
|
||||||
CODE102 = True
|
CODE102 = True
|
||||||
|
|
@ -228,8 +228,9 @@ def parseMap(data, filename):
|
||||||
if event is not None:
|
if event is not None:
|
||||||
# This translates ID of events. (May break the game)
|
# This translates ID of events. (May break the game)
|
||||||
if '<namePop:' in event['note']:
|
if '<namePop:' in event['note']:
|
||||||
totalTokens[0] += translateNoteOmitSpace(event, r'<namePop:(.*?) [\d]+>')[0]
|
response = translateNoteOmitSpace(event, r'<namePop:(.*?)\s.+>')
|
||||||
totalTokens[1] += translateNoteOmitSpace(event, r'<namePop:(.*?) [\d]+>')[1]
|
totalTokens[0] += response[0]
|
||||||
|
totalTokens[1] += response[1]
|
||||||
|
|
||||||
futures = [executor.submit(searchCodes, page, pbar, [], filename) for page in event['pages'] if page is not None]
|
futures = [executor.submit(searchCodes, page, pbar, [], filename) for page in event['pages'] if page is not None]
|
||||||
for future in as_completed(futures):
|
for future in as_completed(futures):
|
||||||
|
|
@ -279,7 +280,7 @@ def translateNoteOmitSpace(event, regex):
|
||||||
jaString = re.sub(r'\n', ' ', oldJAString)
|
jaString = re.sub(r'\n', ' ', oldJAString)
|
||||||
|
|
||||||
# Translate
|
# Translate
|
||||||
response = translateGPT(jaString, 'Reply with the '+ LANGUAGE +' translation of the location name.', True)
|
response = translateGPT(jaString, 'Reply with the '+ LANGUAGE +' translation of the location name.', False)
|
||||||
translatedText = response[0]
|
translatedText = response[0]
|
||||||
|
|
||||||
translatedText = translatedText.replace('\"', '')
|
translatedText = translatedText.replace('\"', '')
|
||||||
|
|
@ -827,9 +828,9 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
codeList[i]['code'] = -1
|
codeList[i]['code'] = -1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check for Speaker
|
# Check for Colored Speaker
|
||||||
coloredSpeakerList = re.findall(r'^[\\]+[cC]\[[\d]+\](.+?)[\\]+[Cc]\[[\d]\]$', jaString)
|
coloredSpeakerList = re.findall(r'^[\\]+[cC]\[[\d]+\](.+?)[\\]+[Cc]\[[\d]\]$', jaString)
|
||||||
if len(coloredSpeakerList) != 0 and len(codeList[i+1]['parameters']) > 0:
|
if len(coloredSpeakerList) != 0 and codeList[i+1]['code'] in [401, 405, -1]:
|
||||||
# Get Speaker
|
# Get Speaker
|
||||||
response = getSpeaker(coloredSpeakerList[0])
|
response = getSpeaker(coloredSpeakerList[0])
|
||||||
speaker = response[0]
|
speaker = response[0]
|
||||||
|
|
@ -1071,7 +1072,7 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
## Event Code: 122 [Set Variables]
|
## Event Code: 122 [Set Variables]
|
||||||
if codeList[i]['code'] == 122 and CODE122 is True:
|
if codeList[i]['code'] == 122 and CODE122 is True:
|
||||||
# This is going to be the var being set. (IMPORTANT)
|
# This is going to be the var being set. (IMPORTANT)
|
||||||
if codeList[i]['parameters'][0] not in [315,316,317,318,319,320,321,322,323,324,325]:
|
if codeList[i]['parameters'][0] not in [528, 944]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
jaString = codeList[i]['parameters'][4]
|
jaString = codeList[i]['parameters'][4]
|
||||||
|
|
@ -1261,6 +1262,7 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
|
|
||||||
## Event Code: 355 or 655 Scripts [Optional]
|
## Event Code: 355 or 655 Scripts [Optional]
|
||||||
if (codeList[i]['code'] == 355 or codeList[i]['code'] == 655) and CODE355655 is True:
|
if (codeList[i]['code'] == 355 or codeList[i]['code'] == 655) and CODE355655 is True:
|
||||||
|
matchList = []
|
||||||
jaString = codeList[i]['parameters'][0]
|
jaString = codeList[i]['parameters'][0]
|
||||||
|
|
||||||
# If there isn't any Japanese in the text just skip
|
# If there isn't any Japanese in the text just skip
|
||||||
|
|
@ -1270,15 +1272,19 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
# Skip These
|
# Skip These
|
||||||
# if 'this.' in jaString:
|
# if 'this.' in jaString:
|
||||||
# continue
|
# continue
|
||||||
|
|
||||||
|
# Need to remove outside code and put it back later
|
||||||
|
# matchList = re.findall(r'.+"(.*?)".*[;,]$', jaString)
|
||||||
|
|
||||||
if 'console.' in jaString:
|
if 'console.' in jaString:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Want to translate this script
|
# Want to translate this script
|
||||||
if 'this.BLogAdd' not in jaString:
|
# if 'this.BLogAdd' not in jaString:
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
# Need to remove outside code and put it back later
|
if '_subject=' in jaString:
|
||||||
matchList = re.findall(r'.+"(.*?)".*[;,]$', jaString)
|
matchList = re.findall(r'.*?subject=(.*?)\".*?', jaString)
|
||||||
|
|
||||||
# Translate
|
# Translate
|
||||||
if len(matchList) > 0:
|
if len(matchList) > 0:
|
||||||
|
|
@ -1287,9 +1293,10 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
# continue
|
# continue
|
||||||
|
|
||||||
# Remove Textwrap
|
# Remove Textwrap
|
||||||
text = matchList[0].replace('\\n', ' ')
|
# text = matchList[0].replace('\\n', ' ')
|
||||||
|
text = matchList[0]
|
||||||
|
|
||||||
response = translateGPT(text, 'Reply with the '+ LANGUAGE +' translation Stat Title. Keep it brief.', False)
|
response = translateGPT(text, 'Reply with the '+ LANGUAGE +' translation. Keep it brief.', False)
|
||||||
totalTokens[0] += response[1][0]
|
totalTokens[0] += response[1][0]
|
||||||
totalTokens[1] += response[1][1]
|
totalTokens[1] += response[1][1]
|
||||||
translatedText = response[0]
|
translatedText = response[0]
|
||||||
|
|
@ -1302,7 +1309,7 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
translatedText = translatedText.replace("'", '\'')
|
translatedText = translatedText.replace("'", '\'')
|
||||||
|
|
||||||
# Wordwrap
|
# Wordwrap
|
||||||
translatedText = textwrap.fill(translatedText, width=60).replace('\n', '\\n')
|
# translatedText = textwrap.fill(translatedText, width=60).replace('\n', '\\n')
|
||||||
|
|
||||||
# Set Data
|
# Set Data
|
||||||
translatedText = jaString.replace(matchList[0], translatedText)
|
translatedText = jaString.replace(matchList[0], translatedText)
|
||||||
|
|
@ -1360,7 +1367,7 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
if 'info:' in jaString:
|
if 'info:' in jaString:
|
||||||
regex = r'info:(.*)'
|
regex = r'info:(.*)'
|
||||||
elif 'ActiveMessage:' in jaString:
|
elif 'ActiveMessage:' in jaString:
|
||||||
regex = r'<ActiveMessage:(.*)>'
|
regex = r'<ActiveMessage:(.*)>?'
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -1369,7 +1376,7 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
|
|
||||||
# Translate
|
# Translate
|
||||||
if len(matchList) > 0:
|
if len(matchList) > 0:
|
||||||
response = translateGPT(matchList[0], 'Reply with the '+ LANGUAGE +' translation of the Title', False)
|
response = translateGPT(matchList[0], 'Reply with the '+ LANGUAGE +' translation of the text.', False)
|
||||||
totalTokens[0] += response[1][0]
|
totalTokens[0] += response[1][0]
|
||||||
totalTokens[1] += response[1][1]
|
totalTokens[1] += response[1][1]
|
||||||
translatedText = response[0]
|
translatedText = response[0]
|
||||||
|
|
@ -1731,10 +1738,10 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
|
|
||||||
# Translate
|
# Translate
|
||||||
if len(textHistory) > 0:
|
if len(textHistory) > 0:
|
||||||
response = translateGPT(choiceList, 'Keep your translation as brief as possible. Previous text for context: ' + textHistory[len(textHistory)-1] + '\n\nThis will be a dialogue option', True)
|
response = translateGPT(choiceList, 'This will be a dialogue option. Previous text for context: ' + textHistory[len(textHistory)-1] + '\n\nThis will be a dialogue option', True)
|
||||||
translatedTextList = response[0]
|
translatedTextList = response[0]
|
||||||
else:
|
else:
|
||||||
response = translateGPT(choiceList, 'Keep your translation as brief as possible.\n\nThis will be a dialogue option', True)
|
response = translateGPT(choiceList, 'This will be a dialogue option', True)
|
||||||
translatedTextList = response[0]
|
translatedTextList = response[0]
|
||||||
|
|
||||||
# Check Mismatch
|
# Check Mismatch
|
||||||
|
|
@ -1742,13 +1749,6 @@ def searchCodes(page, pbar, fillList, filename):
|
||||||
for choice in range(len(codeList[i]['parameters'][0])):
|
for choice in range(len(codeList[i]['parameters'][0])):
|
||||||
translatedText = translatedTextList[choice]
|
translatedText = translatedTextList[choice]
|
||||||
|
|
||||||
# Remove speaker
|
|
||||||
matchSpeakerList = re.findall(r'(^.+?)\s?[|:]\s?', translatedText)
|
|
||||||
if len(matchSpeakerList) > 0:
|
|
||||||
newSpeaker = matchSpeakerList[0]
|
|
||||||
nametag = nametag.replace(speaker, newSpeaker)
|
|
||||||
translatedText = re.sub(r'(^.+?)\s?[|:]\s?', '', translatedText)
|
|
||||||
|
|
||||||
# Set Data
|
# Set Data
|
||||||
totalTokens[0] += response[1][0]
|
totalTokens[0] += response[1][0]
|
||||||
totalTokens[1] += response[1][1]
|
totalTokens[1] += response[1][1]
|
||||||
|
|
@ -2160,13 +2160,12 @@ def batchList(input_list, batch_size):
|
||||||
|
|
||||||
def createContext(fullPromptFlag, subbedT):
|
def createContext(fullPromptFlag, subbedT):
|
||||||
characters = 'Game Characters:\n\
|
characters = 'Game Characters:\n\
|
||||||
ルース (Ruth) - Male\n\
|
ルナ (Luna) - Female\n\
|
||||||
リーザ (Reeza) - Female\n\
|
Taro (Taro) - Male\n\
|
||||||
エリル (Eril) - Female\n\
|
ドルトン (Dalton) - Male\n\
|
||||||
シアン (Cyan) - Female\n\
|
アラシ (Arashi) - Male\n\
|
||||||
トリス (Tris) - Female\n\
|
ボブ (Bob) - Male\n\
|
||||||
エリル (Eril) - Female\n\
|
ショウタ (Syouta) - Male\n\
|
||||||
エリル (Eril) - Female\n\
|
|
||||||
'
|
'
|
||||||
|
|
||||||
system = PROMPT + VOCAB if fullPromptFlag else \
|
system = PROMPT + VOCAB if fullPromptFlag else \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue