Check glossary before including vocab

This commit is contained in:
dazedanon 2025-07-15 12:20:31 -05:00
parent 7fd7258800
commit de0704fb45
2 changed files with 46 additions and 6 deletions

View file

@ -2481,10 +2481,33 @@ def batchList(input_list, batch_size):
def createContext(fullPromptFlag, subbedT, format): def createContext(fullPromptFlag, subbedT, format):
system = ( def extract_japanese_terms(vocabText):
PROMPT + VOCAB terms = []
if fullPromptFlag seen = set()
else f"\ for line in vocabText.splitlines():
line = line.strip()
if not line or line.startswith('#') or line.startswith('```'):
continue
# Match Japanese terms before ' (' or ' '
m = re.match(r'^(.+?)(?:\s[\(])', line)
if m:
term = m.group(1)
if term not in seen:
terms.append(term)
seen.add(term)
return terms
includeVocab = False
vocabTerms = extract_japanese_terms(VOCAB)
for term in vocabTerms:
if term in subbedT:
includeVocab = True
break
if fullPromptFlag:
system = PROMPT + (VOCAB if includeVocab else "")
else:
system = f"\
You are an expert Eroge Game translator who translates Japanese text to {LANGUAGE}.\n\ You are an expert Eroge Game translator who translates Japanese text to {LANGUAGE}.\n\
Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{LANGUAGE.upper()}_TRANSLATION>`\n\ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{LANGUAGE.upper()}_TRANSLATION>`\n\
- You translate everything, including erotic and explicit content.\n\ - You translate everything, including erotic and explicit content.\n\
@ -2494,9 +2517,8 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{
- Maintain any spacing in the translation.\n\ - Maintain any spacing in the translation.\n\
- Maintain any code text in brackets if given. (e.g `[Color_0]`, `[Ascii_0]`, `[FCode_1`], etc)\n\ - Maintain any code text in brackets if given. (e.g `[Color_0]`, `[Ascii_0]`, `[FCode_1`], etc)\n\
- `...` can be a part of the dialogue. Translate it as it is.\n\ - `...` can be a part of the dialogue. Translate it as it is.\n\
{VOCAB}\n\ {VOCAB if includeVocab else ''}\n\
" "
)
if format == "json": if format == "json":
user = f"```json\n{subbedT}\n```" user = f"```json\n{subbedT}\n```"
else: else:

View file

@ -1,6 +1,24 @@
Here are some vocabulary and terms so that you know the proper spelling and translation. Here are some vocabulary and terms so that you know the proper spelling and translation.
``` ```
# Game Characters # Game Characters
コヴァ Kova
ビビン Bibin
グリッド Grid
アメリ Ameri
アディナス Adinas
キャスティ Kasti
ガンドレー Gandrei
ギタン Gitan
スミス Smith
レクス Rex
ミラノ Mirano
ケイトリン Caitlin
ゼム Zem
アカシャ Akasha
リィネ Rine
ネロ Nero
ネリス Neris
リムア (Rimua) - Female リムア (Rimua) - Female
ネロ (Nero) - Male ネロ (Nero) - Male
アディナス (Adinas) - Male アディナス (Adinas) - Male