Fix format
This commit is contained in:
parent
6546d56abe
commit
a669a23f54
22 changed files with 112 additions and 52 deletions
|
|
@ -616,5 +616,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation("\n".join(translatedTextList), False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -575,5 +575,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -621,5 +621,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -743,5 +743,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -625,5 +625,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -759,5 +759,8 @@ def translateGPT(text, history, fullPromptFlag, pbar, filename):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -533,5 +533,8 @@ def translateGPT(text, history, fullPromptFlag, pbar):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -562,5 +562,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -713,5 +713,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation("\n".join(translatedTextList), False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -605,5 +605,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -593,5 +593,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -621,5 +621,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ def translateRegex(data, translatedList):
|
|||
match = re.search(titleRegex, data[i])
|
||||
if match:
|
||||
response = translateGPT(
|
||||
[match.group(1)],
|
||||
match.group(1),
|
||||
f"Reply with the {LANGUAGE} translation of the chapter title",
|
||||
True,
|
||||
)
|
||||
|
|
@ -204,8 +204,8 @@ def translateRegex(data, translatedList):
|
|||
title = response[0]
|
||||
|
||||
# Set
|
||||
if translatedList:
|
||||
title = re.sub(r"(?<!\\)'", r"\\'", title[0])
|
||||
if not translatedList:
|
||||
title = re.sub(r"(?<!\\)'", r"\\'", title)
|
||||
data[i] = data[i].replace(match.group(1), title)
|
||||
|
||||
# Speaker
|
||||
|
|
@ -273,9 +273,9 @@ def translateRegex(data, translatedList):
|
|||
translatedText = re.sub(r"(?<!\\)'", r"\\'", translatedText)
|
||||
|
||||
# Remove Repeating Characters
|
||||
pattern = re.compile(r"(.)\s*\1(?:\s*\1){" + str(10 - 1) + r",}")
|
||||
pattern = re.compile(r"(.)\s*\1(?:\s*\1){" + str(20 - 1) + r",}")
|
||||
translatedText = pattern.sub(
|
||||
lambda match: match.group(0).replace(" ", "")[:10], translatedText
|
||||
lambda match: match.group(0).replace(" ", "")[:20], translatedText
|
||||
)
|
||||
|
||||
# Textwrap
|
||||
|
|
@ -468,9 +468,6 @@ def cleanTranslatedText(translatedText, varResponse):
|
|||
for target, replacement in placeholders.items():
|
||||
translatedText = translatedText.replace(target, replacement)
|
||||
|
||||
# Remove Repeating Characters
|
||||
translatedText = re.sub(r"^(.){10,}$", "\1\1\1\1\1\1\1\1\1\1", translatedText)
|
||||
|
||||
# Elongate Long Dashes (Since GPT Ignores them...)
|
||||
translatedText = elongateCharacters(translatedText)
|
||||
return translatedText
|
||||
|
|
@ -626,8 +623,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [finalList[0], totalTokens]
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -545,5 +545,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -2677,5 +2677,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -2666,5 +2666,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -536,5 +536,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -536,5 +536,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -612,5 +612,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -554,5 +554,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -2474,5 +2474,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -579,5 +579,8 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
Loading…
Reference in a new issue