Make some changes
This commit is contained in:
parent
79d159192b
commit
c2031b6e40
3 changed files with 101 additions and 44 deletions
|
|
@ -176,6 +176,7 @@ def translateOnscripter(data, pbar, filename, translatedList):
|
|||
# Grab Consecutive Strings
|
||||
jaString = match.group(1)
|
||||
while len(data) > i+1 and re.match(regex, data[i+1]):
|
||||
data[i] = ''
|
||||
i += 1
|
||||
jaString = f'{jaString} {data[i]}'
|
||||
|
||||
|
|
@ -183,6 +184,8 @@ def translateOnscripter(data, pbar, filename, translatedList):
|
|||
jaString = jaString.replace('\n', ' ')
|
||||
jaString = jaString.replace('\u3000', '')
|
||||
jaString = jaString.replace('\\', '')
|
||||
jaString = jaString.replace(' >', ')')
|
||||
jaString = jaString.replace('< ', '(')
|
||||
|
||||
# Remove Furigana
|
||||
furiMatch = re.findall(r'({(.+?)\/(.+?)})', jaString)
|
||||
|
|
@ -449,6 +452,7 @@ def cleanTranslatedText(translatedText, varResponse):
|
|||
' >': '>',
|
||||
'「': '\"',
|
||||
'」': '\"',
|
||||
'―': '-',
|
||||
'- ': '-',
|
||||
'Placeholder Text': '',
|
||||
# Add more replacements as needed
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ if 'gpt-3.5' in MODEL:
|
|||
elif 'gpt-4' in MODEL:
|
||||
INPUTAPICOST = .005
|
||||
OUTPUTAPICOST = .015
|
||||
BATCHSIZE = 50
|
||||
BATCHSIZE = 20
|
||||
FREQUENCY_PENALTY = 0.1
|
||||
|
||||
#tqdm Globals
|
||||
|
|
@ -58,18 +58,18 @@ POSITION = 0
|
|||
LEAVE = False
|
||||
|
||||
# Dialogue / Scroll
|
||||
CODE401 = False
|
||||
CODE401 = True
|
||||
CODE405 = False
|
||||
CODE408 = False
|
||||
|
||||
# Choices
|
||||
CODE102 = False
|
||||
CODE102 = True
|
||||
|
||||
# Variables
|
||||
CODE122 = False
|
||||
|
||||
# Names
|
||||
CODE101 = False
|
||||
CODE101 = True
|
||||
|
||||
# Other
|
||||
CODE355655 = False
|
||||
|
|
@ -1247,38 +1247,47 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
continue
|
||||
|
||||
# Force Speaker using var
|
||||
if 'ari' in jaString.lower():
|
||||
speaker = 'Arisa'
|
||||
if '\\ap[1左]' in jaString.lower() or '\\ap[1右]' in jaString.lower():
|
||||
speaker = 'Cecily'
|
||||
i += 1
|
||||
continue
|
||||
elif 'riika' in jaString.lower():
|
||||
speaker = 'Rika'
|
||||
elif '\\ap[2左]' in jaString.lower() or '\\ap[2右]' in jaString.lower():
|
||||
speaker = 'Amelia'
|
||||
i += 1
|
||||
continue
|
||||
elif 'sutera' in jaString.lower():
|
||||
speaker = 'Stella'
|
||||
elif '\\ap[3左]' in jaString.lower() or '\\ap[3右]' in jaString.lower():
|
||||
speaker = 'Henry'
|
||||
i += 1
|
||||
continue
|
||||
elif '\\ap[4左]' in jaString.lower() or '\\ap[4右]' in jaString.lower():
|
||||
speaker = 'Oswald'
|
||||
i += 1
|
||||
continue
|
||||
elif '\\ap' in jaString:
|
||||
speaker = re.search(r'[\\]+AP\[(.*?)\]', jaString).group(1)
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# Get Speaker
|
||||
response = getSpeaker(jaString)
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
speaker = response[0]
|
||||
|
||||
# Validate Speaker is not empty
|
||||
if len(speaker) > 0:
|
||||
if isVar == False:
|
||||
codeList[i]['parameters'][4] = speaker
|
||||
i += 1
|
||||
continue
|
||||
if '\\' not in jaString:
|
||||
response = getSpeaker(jaString)
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
speaker = response[0]
|
||||
|
||||
# Validate Speaker is not empty
|
||||
if len(speaker) > 0:
|
||||
if isVar == False:
|
||||
codeList[i]['parameters'][4] = speaker
|
||||
i += 1
|
||||
continue
|
||||
else:
|
||||
codeList[i]['parameters'][0] = speaker
|
||||
isVar = False
|
||||
i += 1
|
||||
continue
|
||||
else:
|
||||
codeList[i]['parameters'][0] = speaker
|
||||
isVar = False
|
||||
i += 1
|
||||
continue
|
||||
else:
|
||||
speaker = ''
|
||||
speaker = ''
|
||||
|
||||
## Event Code: 355 or 655 Scripts [Optional]
|
||||
if 'code' in codeList[i] and (codeList[i]['code'] == 355 or codeList[i]['code'] == 655) and CODE355655 is True:
|
||||
|
|
@ -2003,7 +2012,7 @@ def subVars(jaString):
|
|||
|
||||
# Colors
|
||||
count = 0
|
||||
colorList = re.findall(r'[\\]+[cC]\[[0-9]+\]', jaString)
|
||||
colorList = re.findall(r'([\\]+c\[\d+\][\\]+c|[\\]+c\[\d+\])', jaString)
|
||||
colorList = set(colorList)
|
||||
if len(colorList) != 0:
|
||||
for color in colorList:
|
||||
|
|
@ -2101,7 +2110,11 @@ def batchList(input_list, batch_size):
|
|||
|
||||
def createContext(fullPromptFlag, subbedT):
|
||||
characters = 'Game Characters:\n\
|
||||
カエデ (Kaede) - Female\n\
|
||||
セシリー (Cecily) - Female\n\
|
||||
アメリア (Amelia) - Female\n\
|
||||
ヘンリー (Henry) - Male\n\
|
||||
オズワルド (Oswald) - Male\n\
|
||||
ダミアーニ (Damian) - Male\n\
|
||||
'
|
||||
|
||||
system = PROMPT + VOCAB if fullPromptFlag else \
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ CODE300 = True
|
|||
CODE250 = False
|
||||
|
||||
# Database
|
||||
NPCFLAG = False
|
||||
NPCFLAG = True
|
||||
SCENARIOFLAG = False
|
||||
ITEMFLAG = False
|
||||
COLLECTIONFLAG = True
|
||||
COLLECTIONFLAG = False
|
||||
ARMORFLAG = False
|
||||
ENEMYFLAG = False
|
||||
WEAPONFLAG = False
|
||||
|
|
@ -569,21 +569,19 @@ def searchDB(events, pbar, jobList, filename):
|
|||
try:
|
||||
for table in tableList:
|
||||
|
||||
# Translate NPC Table
|
||||
# Grab Scenarios
|
||||
# Grab Items
|
||||
if table['name'] == '万能型用語辞典' and NPCFLAG == True:
|
||||
# Translate NPC
|
||||
if table['name'] == '主人公ステータス' and NPCFLAG == True:
|
||||
for npc in table['data']:
|
||||
dataList = npc['data']
|
||||
|
||||
# Parse
|
||||
for j in range(len(dataList)):
|
||||
# Name
|
||||
if 'ルール名' in dataList[j].get('name'):
|
||||
if 'スペシャルゲージ名称' in dataList[j].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
NPCList[0].append(dataList[0].get('value'))
|
||||
NPCList[0].append(dataList[j].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
|
|
@ -592,7 +590,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
NPCList[0].pop(0)
|
||||
|
||||
# Description
|
||||
if 'ルール内容' in dataList[j].get('name'):
|
||||
if 'NULL' in dataList[j].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
|
|
@ -618,7 +616,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
NPCList[1].pop(0)
|
||||
|
||||
# Description
|
||||
if '詳しく説明をだな' in dataList[j].get('name'):
|
||||
if 'NULL' in dataList[j].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
|
|
@ -682,7 +680,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
itemList[0].append(dataList[0].get('value'))
|
||||
itemList[0].append(dataList[j].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
|
|
@ -780,7 +778,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
armorList[0].append(dataList[0].get('value'))
|
||||
armorList[0].append(dataList[j].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
|
|
@ -825,7 +823,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
enemyList[0].append(dataList[0].get('value'))
|
||||
enemyList[0].append(dataList[j].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
|
|
@ -870,7 +868,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
weaponsList[0].append(dataList[0].get('value'))
|
||||
weaponsList[0].append(dataList[j].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
|
|
@ -994,7 +992,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
|
||||
# Translation
|
||||
scenarioListTL = [[],[],[]]
|
||||
NPCListTL = []
|
||||
NPCListTL = [[],[],[],[]]
|
||||
itemListTL = [[],[],[],[]]
|
||||
collectionListTL = [[],[],[],[]]
|
||||
armorListTL = [[],[]]
|
||||
|
|
@ -1003,6 +1001,48 @@ def searchDB(events, pbar, jobList, filename):
|
|||
|
||||
translate = False
|
||||
|
||||
# NPCs
|
||||
if len(NPCList[0]) > 0:
|
||||
# Progress Bar
|
||||
total = 0
|
||||
for itemArray in NPCList:
|
||||
total += len(itemArray)
|
||||
pbar.total = total
|
||||
pbar.refresh()
|
||||
|
||||
# Name
|
||||
response = translateGPT(NPCList[0], 'Reply with only the '+ LANGUAGE +' translation of the RPG item name', True, pbar, filename)
|
||||
nameListTL = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
# Desc 1
|
||||
response = translateGPT(NPCList[1], 'Reply with only the '+ LANGUAGE +' translation', True, pbar, filename)
|
||||
descListTL1 = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
# Desc 2
|
||||
response = translateGPT(NPCList[2], 'Reply with only the '+ LANGUAGE +' translation', True, pbar, filename)
|
||||
descListTL2 = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
# Desc 3
|
||||
response = translateGPT(NPCList[3], 'Reply with only the '+ LANGUAGE +' translation', True, pbar, filename)
|
||||
descListTL3 = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
|
||||
# Check Mismatch
|
||||
if len(nameListTL) != len(NPCList[0]) or\
|
||||
len(descListTL1) != len(NPCList[1]) or\
|
||||
len(descListTL2) != len(NPCList[2])or\
|
||||
len(descListTL3) != len(NPCList[3]):
|
||||
with LOCK:
|
||||
if filename not in MISMATCH:
|
||||
MISMATCH.append(filename)
|
||||
else:
|
||||
NPCListTL = [nameListTL, descListTL1, descListTL2, descListTL3]
|
||||
translate = True
|
||||
|
||||
# SCENARIO
|
||||
if len(scenarioList[0]) > 0:
|
||||
# Progress Bar
|
||||
|
|
|
|||
Loading…
Reference in a new issue