From de0704fb454114b73488789f57bd2d3d05d843ed Mon Sep 17 00:00:00 2001 From: dazedanon Date: Tue, 15 Jul 2025 12:20:31 -0500 Subject: [PATCH] Check glossary before including vocab --- modules/rpgmakermvmz.py | 34 ++++++++++++++++++++++++++++------ vocab.txt | 18 ++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 5847155..0a0f3e9 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -2481,10 +2481,33 @@ def batchList(input_list, batch_size): def createContext(fullPromptFlag, subbedT, format): - system = ( - PROMPT + VOCAB - if fullPromptFlag - else f"\ + def extract_japanese_terms(vocabText): + terms = [] + seen = set() + 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\ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{LANGUAGE.upper()}_TRANSLATION>`\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 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\ -{VOCAB}\n\ +{VOCAB if includeVocab else ''}\n\ " - ) if format == "json": user = f"```json\n{subbedT}\n```" else: diff --git a/vocab.txt b/vocab.txt index a458492..b14447e 100644 --- a/vocab.txt +++ b/vocab.txt @@ -1,6 +1,24 @@ Here are some vocabulary and terms so that you know the proper spelling and translation. ``` # Game Characters +コヴァ – Kova +ビビン – Bibin +グリッド – Grid +アメリ – Ameri +アディナス – Adinas +キャスティ – Kasti +ガンドレー – Gandrei +ギタン – Gitan +スミス – Smith +レクス – Rex +ミラノ – Mirano +ケイトリン – Caitlin +ゼム – Zem +アカシャ – Akasha +リィネ – Rine +ネロ – Nero +ネリス – Neris + リムア (Rimua) - Female ネロ (Nero) - Male アディナス (Adinas) - Male