Few improvements to the engines
This commit is contained in:
parent
9b21d4f1c4
commit
f57663553c
4 changed files with 63 additions and 53 deletions
|
|
@ -1042,11 +1042,11 @@ def searchCodes(page, pbar, fillList, filename):
|
|||
|
||||
# Remove speaker
|
||||
if speaker != '':
|
||||
matchSpeakerList = re.findall(r'(^.+?)\s?[|:]\s?', translatedText)
|
||||
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)
|
||||
translatedText = re.sub(r'^\[?(.+?)\]?\s?[|:]\s?', '', translatedText)
|
||||
|
||||
# Textwrap
|
||||
if FIXTEXTWRAP is True:
|
||||
|
|
|
|||
|
|
@ -56,18 +56,18 @@ POSITION = 0
|
|||
LEAVE = False
|
||||
|
||||
# Dialogue / Scroll
|
||||
CODE401 = False
|
||||
CODE405 = False
|
||||
CODE401 = True
|
||||
CODE405 = True
|
||||
CODE408 = False
|
||||
|
||||
# Choices
|
||||
CODE102 = False
|
||||
CODE102 = True
|
||||
|
||||
# Variables
|
||||
CODE122 = False
|
||||
|
||||
# Names
|
||||
CODE101 = True
|
||||
CODE101 = False
|
||||
|
||||
# Other
|
||||
CODE355655 = False
|
||||
|
|
@ -838,10 +838,10 @@ def searchCodes(page, pbar, fillList, filename):
|
|||
### \\n<Speaker>
|
||||
nCase = None
|
||||
if finalJAString[0] != '\\':
|
||||
regex = r'(.*?)([\\]+[nN][wWcC]?<(.*?)>.*)'
|
||||
regex = r'(.*?)([\\]+[kKnN][wWcC]?[<\[](.*?)[>\]].*)'
|
||||
nCase = 0
|
||||
else:
|
||||
regex = r'(.*[\\]+[nN][wWcC]?<(.*?)>)(.*)'
|
||||
regex = r'(.*[\\]+[kKnN][wWcC]?[<\[](.*?)[\]>])(.*)'
|
||||
nCase = 1
|
||||
matchList = re.findall(regex, finalJAString)
|
||||
if len(matchList) > 0:
|
||||
|
|
@ -920,7 +920,6 @@ def searchCodes(page, pbar, fillList, filename):
|
|||
|
||||
# Remove Extra Stuff bad for translation.
|
||||
finalJAString = finalJAString.replace('゙', '')
|
||||
finalJAString = finalJAString.replace(' ', '.')
|
||||
finalJAString = finalJAString.replace('―', '-')
|
||||
finalJAString = finalJAString.replace('ー', '-')
|
||||
finalJAString = finalJAString.replace('…', '...')
|
||||
|
|
@ -929,10 +928,10 @@ def searchCodes(page, pbar, fillList, filename):
|
|||
finalJAString = finalJAString.replace(' ', '')
|
||||
|
||||
# Remove any RPGMaker Code at start
|
||||
ffMatchList = re.findall(r'[\\]+[fFaA]+\[.+?\]', finalJAString)
|
||||
if len(ffMatchList) > 0:
|
||||
finalJAString = finalJAString.replace(ffMatchList[0], '')
|
||||
nametag += ffMatchList[0]
|
||||
ffMatch = re.search(r'^([.\\]+[aAbBcCdDeEfFgGhHiIjJlLmMoOpPqQrRsStTuUvVwWxXyYzZ]+\[.+?\])+', finalJAString)
|
||||
if ffMatch != None:
|
||||
finalJAString = finalJAString.replace(ffMatch.group(0), '')
|
||||
nametag += ffMatch.group(0)
|
||||
|
||||
### Remove format codes
|
||||
# Furigana
|
||||
|
|
@ -985,11 +984,11 @@ def searchCodes(page, pbar, fillList, filename):
|
|||
|
||||
# Remove speaker
|
||||
if speaker != '':
|
||||
matchSpeakerList = re.findall(r'(^.+?)\s?[|:]\s?', translatedText)
|
||||
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)
|
||||
translatedText = re.sub(r'^\[?(.+?)\]?\s?[|:]\s?', '', translatedText)
|
||||
|
||||
# Textwrap
|
||||
if FIXTEXTWRAP is True:
|
||||
|
|
@ -2105,14 +2104,13 @@ def batchList(input_list, batch_size):
|
|||
|
||||
def createContext(fullPromptFlag, subbedT):
|
||||
characters = 'Game Characters:\n\
|
||||
シラス ティア ナナシユエル (Silas Tia Nanasiyuel) - Female\n\
|
||||
レイラ プラム ナナシユエル (Leila Plum Nanasiyuel) - Female\n\
|
||||
アリア グランツ (Aria Granz) - Female\n\
|
||||
ソフィー グリーンウッド (Sophie Greenwood) - Female\n\
|
||||
ヨウコ マッカーシー (Yoko McCarthy) - Female\n\
|
||||
ルフィナ アリーニア (Rufina Arinia) - Female\n\
|
||||
ヘレナ ルオ アルバネル (Helena Luo Albaner) - Female\n\
|
||||
アウローラ パパス (Aurora Pappas) - Female\n\
|
||||
クロア (Croix) - Female\n\
|
||||
月影 (Tsukikage) - Female\n\
|
||||
あろま (Aroma) - Female\n\
|
||||
フトシ (Futoshi) - Male\n\
|
||||
ユウナ (Shuu) - Male\n\
|
||||
嵐野 (Arashino) - Male\n\
|
||||
鬼瓦 (Onigawara) - Male\n\
|
||||
'
|
||||
|
||||
system = PROMPT + VOCAB if fullPromptFlag else \
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ POSITION = 0
|
|||
LEAVE = False
|
||||
|
||||
# Dialogue / Scroll
|
||||
CODE101 = True
|
||||
CODE102 = True
|
||||
CODE101 = False
|
||||
CODE102 = False
|
||||
CODE122 = False
|
||||
|
||||
# Other
|
||||
|
|
@ -656,21 +656,21 @@ def searchDB(events, pbar, jobList, filename):
|
|||
if setData == False:
|
||||
if dataList[1].get('value') != '':
|
||||
scenarioList[0].append(dataList[1].get('value'))
|
||||
if dataList[15].get('value') != '':
|
||||
scenarioList[1].append(dataList[15].get('value'))
|
||||
if dataList[77].get('value') != '':
|
||||
scenarioList[2].append(dataList[77].get('value'))
|
||||
if dataList[74].get('value') != '':
|
||||
scenarioList[1].append(dataList[74].get('value'))
|
||||
if dataList[75].get('value') != '':
|
||||
scenarioList[2].append(dataList[75].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
if dataList[1].get('value') != '':
|
||||
dataList[1].update({'value': scenarioList[0][0]})
|
||||
scenarioList[0].pop(0)
|
||||
if dataList[15].get('value') != '':
|
||||
dataList[15].update({'value': scenarioList[1][0]})
|
||||
if dataList[74].get('value') != '':
|
||||
dataList[74].update({'value': scenarioList[1][0]})
|
||||
scenarioList[1].pop(0)
|
||||
if dataList[77].get('value') != '':
|
||||
dataList[77].update({'value': scenarioList[2][0]})
|
||||
if dataList[75].get('value') != '':
|
||||
dataList[75].update({'value': scenarioList[2][0]})
|
||||
scenarioList[2].pop(0)
|
||||
|
||||
# Grab Items
|
||||
|
|
@ -720,32 +720,32 @@ def searchDB(events, pbar, jobList, filename):
|
|||
armorList[1].pop(0)
|
||||
|
||||
# Grab Other
|
||||
if table['name'] == 'バステ' and OTHERFLAG == True:
|
||||
if table['name'] == 'ダンジョン敵' and OTHERFLAG == True:
|
||||
for other in table['data']:
|
||||
dataList = other['data']
|
||||
|
||||
# Parse
|
||||
if 'バステ名' in dataList[0].get('name'):
|
||||
if '名前' in dataList[0].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[0].get('value') != '':
|
||||
otherList[0].append(dataList[0].get('value'))
|
||||
if dataList[1].get('value') != '':
|
||||
otherList[1].append('Taro' + dataList[1].get('value'))
|
||||
if dataList[2].get('value') != '':
|
||||
otherList[2].append('Taro' + dataList[2].get('value'))
|
||||
# if dataList[1].get('value') != '':
|
||||
# otherList[1].append('Taro' + dataList[1].get('value'))
|
||||
# if dataList[2].get('value') != '':
|
||||
# otherList[2].append('Taro' + dataList[2].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
if dataList[0].get('value') != '':
|
||||
dataList[0].update({'value': otherList[0][0]})
|
||||
otherList[0].pop(0)
|
||||
if dataList[1].get('value') != '':
|
||||
dataList[1].update({'value': otherList[1][0].replace('Taro', '')})
|
||||
otherList[1].pop(0)
|
||||
if dataList[2].get('value') != '':
|
||||
dataList[2].update({'value': otherList[2][0].replace('Taro', '')})
|
||||
otherList[2].pop(0)
|
||||
# if dataList[1].get('value') != '':
|
||||
# dataList[1].update({'value': otherList[1][0].replace('Taro', '')})
|
||||
# otherList[1].pop(0)
|
||||
# if dataList[2].get('value') != '':
|
||||
# dataList[2].update({'value': otherList[2][0].replace('Taro', '')})
|
||||
# otherList[2].pop(0)
|
||||
|
||||
# Grab Collection
|
||||
if table['name'] == '採取' and COLLECTIONFLAG == True:
|
||||
|
|
@ -753,14 +753,26 @@ def searchDB(events, pbar, jobList, filename):
|
|||
dataList = object['data']
|
||||
|
||||
# Parse
|
||||
if dataList[0].get('value') != '' and dataList[0].get('name') == 'オブジェクト名':
|
||||
if dataList[15].get('value') != '' and dataList[0].get('name') == 'オブジェクト名':
|
||||
# Pass 1 (Grab Data)
|
||||
jaString = dataList[15].get('value')
|
||||
speaker = re.search(r'(.*):\r\n', jaString)
|
||||
if setData == False:
|
||||
collectionList.append(dataList[0].get('value'))
|
||||
collectionList.append(dataList[15].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
dataList[0].update({'value': collectionList[0]})
|
||||
if speaker == None:
|
||||
# Remove speaker
|
||||
matchSpeakerList = re.findall(r'^(\[.+?\]\s?[|:]\s?)\s?', collectionList[0])
|
||||
if len(matchSpeakerList) > 0:
|
||||
collectionList[0] = collectionList[0].replace(matchSpeakerList[0], '')
|
||||
else:
|
||||
# Reformat Speaker
|
||||
matchSpeaker = re.search(r'^\[(.+?)\]\s?[|:]\s?\s?(.+)', collectionList[0])
|
||||
if matchSpeaker != None:
|
||||
collectionList[0] = f'{matchSpeaker.group(1)}:\r\n{matchSpeaker.group(2)}'
|
||||
dataList[15].update({'value': collectionList[0]})
|
||||
collectionList.pop(0)
|
||||
|
||||
# Translation
|
||||
|
|
@ -793,7 +805,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
# Desc 2
|
||||
response = translateGPT(scenarioList[2], 'Reply with only the '+ LANGUAGE +' translation', True, pbar, filename)
|
||||
response = translateGPT(scenarioList[2], 'reply with only the gender neutral '+ LANGUAGE +' translation of the NPC name', True, pbar, filename)
|
||||
descListTL2 = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
|
|
@ -920,7 +932,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
pbar.refresh()
|
||||
|
||||
# Name
|
||||
response = translateGPT(collectionList, 'Reply with only the '+ LANGUAGE +' translation of the RPG item name', True, pbar, filename)
|
||||
response = translateGPT(collectionList, 'Reply with only the '+ LANGUAGE +' translation', True, pbar, filename)
|
||||
collectionListTL = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ def getResultString(translatedData, translationTime, filename):
|
|||
errorString + Fore.RESET
|
||||
|
||||
def openFiles(filename):
|
||||
with open('files/' + filename, 'r', encoding='utf-8') as readFile:
|
||||
with open('files/' + filename, 'r', encoding='shift_jis') as readFile:
|
||||
translatedData = parseWOLF(readFile, filename)
|
||||
|
||||
# Delete lines marked for deletion
|
||||
|
|
@ -172,7 +172,7 @@ def translateWOLF(data, pbar, filename, translatedList):
|
|||
speaker = ''
|
||||
|
||||
# Lines
|
||||
if r'/dfsdsfs' in data[i] and data[i] != '\n':
|
||||
if r'/' not in data[i] and data[i] != '\n':
|
||||
# Pass 1
|
||||
if translatedList == []:
|
||||
# Grab Consecutive Strings
|
||||
|
|
@ -184,7 +184,7 @@ def translateWOLF(data, pbar, filename, translatedList):
|
|||
|
||||
# Join up 401 groups for better translation.
|
||||
if len(currentGroup) > 0:
|
||||
jaString = ' '.join(currentGroup)
|
||||
jaString = ''.join(currentGroup)
|
||||
currentGroup = []
|
||||
|
||||
# Remove any textwrap
|
||||
|
|
|
|||
Loading…
Reference in a new issue