Update pricing and other stuff
This commit is contained in:
parent
33c33dfb5e
commit
7158934d87
5 changed files with 34 additions and 16 deletions
|
|
@ -572,6 +572,7 @@ def elongateCharacters(text):
|
|||
|
||||
def extractTranslation(translatedTextList, is_list):
|
||||
try:
|
||||
translatedTextList = re.sub(r'\\"+\"([^,\n}])', r'\\"\1', translatedTextList)
|
||||
line_dict = json.loads(translatedTextList)
|
||||
# If it's a batch (i.e., list), extract with tags; otherwise, return the single item.
|
||||
string_list = list(line_dict.values())
|
||||
|
|
@ -581,7 +582,7 @@ def extractTranslation(translatedTextList, is_list):
|
|||
return string_list[0]
|
||||
|
||||
except Exception as e:
|
||||
print(f'extractTranslation Error: {translatedTextList}')
|
||||
PBAR.write(f'extractTranslation Error: {e} on String {translatedTextList}')
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ if 'gpt-3.5' in MODEL:
|
|||
BATCHSIZE = 10
|
||||
FREQUENCY_PENALTY = 0.2
|
||||
elif 'gpt-4' in MODEL:
|
||||
INPUTAPICOST = .005
|
||||
OUTPUTAPICOST = .015
|
||||
INPUTAPICOST = .0025
|
||||
OUTPUTAPICOST = .01
|
||||
BATCHSIZE = 20
|
||||
FREQUENCY_PENALTY = 0.1
|
||||
|
||||
|
|
@ -820,7 +820,10 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
and len(codeList[i+1]['p']) > 0 \
|
||||
and len(codeList[i+1]['p'][0]) > 0:
|
||||
if codeList[i+1]['p'][0].strip()[0] in ['「', '"', '(', '(', '*', '[']:
|
||||
speakerList = re.findall(r'.+', jaString)
|
||||
# Make sure there aren't any codes.
|
||||
speakerList = re.findall(r'[\\]\w\[.*?\](.*)', jaString)
|
||||
if len(speakerList) == 0:
|
||||
speakerList = re.findall(r'.*', jaString)
|
||||
|
||||
if len(speakerList) != 0 and codeList[i+1]['c'] in [401, 405, -1]:
|
||||
# Get Speaker
|
||||
|
|
@ -2143,7 +2146,7 @@ def createContext(fullPromptFlag, subbedT, format):
|
|||
characters = 'Game Characters:\n\
|
||||
アーベント (Abent) - Male\n\
|
||||
グイーネ (Guine) - Female\n\
|
||||
ゲオルイース (Geoluis) - Female\n\
|
||||
ゲオルイース (Geolouise) - Female\n\
|
||||
サミダレクモ (Samidarekumo) - Female\n\
|
||||
スティアラ (Stiara) - Female\n\
|
||||
ブルウ (Blue) - Male\n\
|
||||
|
|
@ -2238,6 +2241,7 @@ def elongateCharacters(text):
|
|||
|
||||
def extractTranslation(translatedTextList, is_list):
|
||||
try:
|
||||
translatedTextList = re.sub(r'\\"+\"([^,\n}])', r'\\"\1', translatedTextList)
|
||||
line_dict = json.loads(translatedTextList)
|
||||
# If it's a batch (i.e., list), extract with tags; otherwise, return the single item.
|
||||
string_list = list(line_dict.values())
|
||||
|
|
@ -2247,7 +2251,7 @@ def extractTranslation(translatedTextList, is_list):
|
|||
return string_list[0]
|
||||
|
||||
except Exception as e:
|
||||
print(f'extractTranslation Error: {e}')
|
||||
PBAR.write(f'extractTranslation Error: {e} on String {translatedTextList}')
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -493,6 +493,7 @@ def elongateCharacters(text):
|
|||
|
||||
def extractTranslation(translatedTextList, is_list):
|
||||
try:
|
||||
translatedTextList = re.sub(r'\\"+\"([^,\n}])', r'\\"\1', translatedTextList)
|
||||
line_dict = json.loads(translatedTextList)
|
||||
# If it's a batch (i.e., list), extract with tags; otherwise, return the single item.
|
||||
string_list = list(line_dict.values())
|
||||
|
|
@ -502,7 +503,7 @@ def extractTranslation(translatedTextList, is_list):
|
|||
return string_list[0]
|
||||
|
||||
except Exception as e:
|
||||
print(f'extractTranslation Error: {translatedTextList}')
|
||||
PBAR.write(f'extractTranslation Error: {e} on String {translatedTextList}')
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ def searchCodes(events, pbar, jobList, filename):
|
|||
codeList[i]['stringArgs'][0] = translatedText
|
||||
|
||||
### Event Code: 300 Common Events
|
||||
if codeList[i]['code'] == 300 and CODE300 == True:
|
||||
if codeList[i]['code'] == 300 and CODE300 == True and len(codeList[i]['stringArgs']) > 1:
|
||||
# Choices
|
||||
if codeList[i]['stringArgs'][0] == "選択肢/確認":
|
||||
# Grab String
|
||||
|
|
@ -514,8 +514,10 @@ def searchCodes(events, pbar, jobList, filename):
|
|||
codeList[i]['stringArgs'][1] = translatedText
|
||||
|
||||
# Dialogue
|
||||
elif codeList[i]['stringArgs'][0] == "Hメッセージ":
|
||||
imageRegex = r'(\\?r?\\?n?_\w+\r\n)|(@-?\d?)(\d?-?\d?[^\r]+?)(\r\n|$)|(_PDC)|(>\r\n)|(^[#])|(\r\n@$)|(/)|(_SS_)|(\r\n[@/]-?\d?\r\n)'
|
||||
elif codeList[i]['stringArgs'][0] == "Hメッセージ" \
|
||||
or codeList[i]['stringArgs'][0] == 'Hしらべる' \
|
||||
or codeList[i]['stringArgs'][0] == '[移]サウンドノベル':
|
||||
imageRegex = r'(\r?\n?_\w+\r?\n?)|(@-?\d?\r\n)|(@-?\d?[^\r])(\d?-?\d?[^\r]+?)(\r\n|$)|(_PDC)|(>\r\n)|(^[#])|(\r\n@$)|(/)|(_SS_)|(\r\n[@/]-?\d?\r\n)'
|
||||
fontSize = 24
|
||||
|
||||
# Grab String
|
||||
|
|
@ -533,7 +535,7 @@ def searchCodes(events, pbar, jobList, filename):
|
|||
j = 0
|
||||
translatedText = ''
|
||||
while j < len(cleanedList):
|
||||
if ('@' in cleanedList[j] or '/' in cleanedList[j]) and j < len(cleanedList)-1 and re.search(r'(\r\n[@/]-?\d?\r\n)', cleanedList[j]) is None:
|
||||
if ('@' in cleanedList[j] or '/' in cleanedList[j]) and j < len(cleanedList)-1 and re.search(r'([@/]-?\d?\r\n)', cleanedList[j]) is None:
|
||||
# Setup @
|
||||
if j > 0 and '@' not in cleanedList[j-1] and '/' not in cleanedList[j-1] and '_' not in cleanedList[j-1]:
|
||||
cleanedList[j-1] = cleanedList[j-1] + cleanedList[j+1]
|
||||
|
|
@ -556,6 +558,12 @@ def searchCodes(events, pbar, jobList, filename):
|
|||
# Pass 2
|
||||
else:
|
||||
if all(x not in str for x in ['_', '@', '>', '/',]) and str != '\r\n':
|
||||
# Decide Wrap
|
||||
if codeList[i]['stringArgs'][0] == '[移]サウンドノベル':
|
||||
width = 50
|
||||
else:
|
||||
width = WIDTH
|
||||
|
||||
# Add Textwrap and Font
|
||||
list300[0] = textwrap.fill(list300[0], WIDTH)
|
||||
list300[0] = list300[0].replace('\n', f'\r\n\\f[{fontSize}]')
|
||||
|
|
@ -569,6 +577,7 @@ def searchCodes(events, pbar, jobList, filename):
|
|||
if setData:
|
||||
# Formatting Fixes
|
||||
translatedText = translatedText.replace('*"', '* "')
|
||||
translatedText = re.sub(r'[^\S\r\n]+', ' ', translatedText)
|
||||
codeList[i]['stringArgs'][1] = translatedText
|
||||
|
||||
### Event Code: 250 Common Events
|
||||
|
|
@ -1545,6 +1554,7 @@ def createContext(fullPromptFlag, subbedT):
|
|||
ブライ (Buraimu) - Male\n\
|
||||
ハッサン (Hassan) - Male\n\
|
||||
アロマ (Aroma) - Female\n\
|
||||
ピッケ (Pikke) - Female\n\
|
||||
'
|
||||
|
||||
system = PROMPT + VOCAB if fullPromptFlag else \
|
||||
|
|
@ -1634,6 +1644,7 @@ def elongateCharacters(text):
|
|||
|
||||
def extractTranslation(translatedTextList, is_list):
|
||||
try:
|
||||
translatedTextList = re.sub(r'\\"+\"([^,\n}])', r'\\"\1', translatedTextList)
|
||||
line_dict = json.loads(translatedTextList)
|
||||
# If it's a batch (i.e., list), extract with tags; otherwise, return the single item.
|
||||
string_list = list(line_dict.values())
|
||||
|
|
@ -1643,7 +1654,7 @@ def extractTranslation(translatedTextList, is_list):
|
|||
return string_list[0]
|
||||
|
||||
except Exception as e:
|
||||
print(f'extractTranslation Error: {translatedTextList}')
|
||||
PBAR.write(f'extractTranslation Error: {e} on String {translatedTextList}')
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -205,13 +205,13 @@ def translateWOLF(data, translatedList, pbar, filename):
|
|||
MISMATCH.append(filename)
|
||||
|
||||
# Lines
|
||||
if r'/' not in data[i] and data[i] != '\n':
|
||||
if r'/' not in data[i] and '@' not in data[i] and data[i] != '\n':
|
||||
# Pass 1
|
||||
if translatedList == []:
|
||||
# Grab Consecutive Strings
|
||||
currentGroup.append(data[i])
|
||||
i += 1
|
||||
while i < len(data) and r'/' not in data[i] and data[i] != '\n':
|
||||
while i < len(data) and r'/' not in data[i] and '@' not in data[i] and data[i] != '\n':
|
||||
currentGroup.append(data[i])
|
||||
i += 1
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ def translateWOLF(data, translatedList, pbar, filename):
|
|||
# Pass 2
|
||||
else:
|
||||
# Insert Strings
|
||||
while i < len(data) and r'/' not in data[i] and data[i] != '\n':
|
||||
while i < len(data) and r'/' not in data[i] and '@' not in data[i] and data[i] != '\n':
|
||||
data.pop(i)
|
||||
|
||||
# Get Text
|
||||
|
|
@ -449,6 +449,7 @@ def elongateCharacters(text):
|
|||
|
||||
def extractTranslation(translatedTextList, is_list):
|
||||
try:
|
||||
translatedTextList = re.sub(r'\\"+\"([^,\n}])', r'\\"\1', translatedTextList)
|
||||
line_dict = json.loads(translatedTextList)
|
||||
# If it's a batch (i.e., list), extract with tags; otherwise, return the single item.
|
||||
string_list = list(line_dict.values())
|
||||
|
|
@ -458,7 +459,7 @@ def extractTranslation(translatedTextList, is_list):
|
|||
return string_list[0]
|
||||
|
||||
except Exception as e:
|
||||
print(f'extractTranslation Error: {translatedTextList}')
|
||||
PBAR.write(f'extractTranslation Error: {e} on String {translatedTextList}')
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue