GameSentenceMiner 2.8.6__py3-none-any.whl → 2.8.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- GameSentenceMiner/ai/ai_prompting.py +201 -0
- GameSentenceMiner/anki.py +4 -3
- GameSentenceMiner/config_gui.py +42 -12
- GameSentenceMiner/configuration.py +39 -15
- GameSentenceMiner/gametext.py +26 -34
- GameSentenceMiner/gsm.py +58 -42
- GameSentenceMiner/obs.py +47 -24
- GameSentenceMiner/ocr/owocr_area_selector.py +4 -2
- GameSentenceMiner/ocr/owocr_helper.py +32 -3
- GameSentenceMiner/owocr/owocr/config.py +3 -1
- GameSentenceMiner/owocr/owocr/run.py +78 -6
- GameSentenceMiner/web/{static → templates}/utility.html +130 -20
- GameSentenceMiner/web/texthooking_page.py +172 -15
- {gamesentenceminer-2.8.6.dist-info → gamesentenceminer-2.8.8.dist-info}/METADATA +2 -1
- {gamesentenceminer-2.8.6.dist-info → gamesentenceminer-2.8.8.dist-info}/RECORD +20 -20
- {gamesentenceminer-2.8.6.dist-info → gamesentenceminer-2.8.8.dist-info}/WHEEL +1 -1
- GameSentenceMiner/ai/gemini.py +0 -143
- /GameSentenceMiner/web/{static → templates}/text_replacements.html +0 -0
- {gamesentenceminer-2.8.6.dist-info → gamesentenceminer-2.8.8.dist-info}/entry_points.txt +0 -0
- {gamesentenceminer-2.8.6.dist-info → gamesentenceminer-2.8.8.dist-info}/licenses/LICENSE +0 -0
- {gamesentenceminer-2.8.6.dist-info → gamesentenceminer-2.8.8.dist-info}/top_level.txt +0 -0
GameSentenceMiner/ai/gemini.py
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
import google.generativeai as genai
|
2
|
-
|
3
|
-
from GameSentenceMiner.configuration import get_config, logger
|
4
|
-
|
5
|
-
MODEL = "gemini-2.0-flash" # or "gemini-pro-vision" if you need image support
|
6
|
-
|
7
|
-
genai.configure(api_key=get_config().ai.api_key)
|
8
|
-
model = genai.GenerativeModel(MODEL)
|
9
|
-
|
10
|
-
def translate_with_context(lines, sentence, current_line_index, game_title=""):
|
11
|
-
"""
|
12
|
-
Translates a line of dialogue with context from surrounding lines.
|
13
|
-
|
14
|
-
Args:
|
15
|
-
lines: A list of strings representing the dialogue lines.
|
16
|
-
sentence: Sentence to get translation for
|
17
|
-
current_line_index: The index of the line to translate.
|
18
|
-
game_title: Optional title of the game for added context.
|
19
|
-
|
20
|
-
Returns:
|
21
|
-
A string containing the translated sentence with context.
|
22
|
-
"""
|
23
|
-
|
24
|
-
if not lines or current_line_index < 0 or current_line_index >= len(lines):
|
25
|
-
return "Invalid input."
|
26
|
-
|
27
|
-
context_lines = []
|
28
|
-
|
29
|
-
# Get the previous 10 lines (or fewer if at the beginning)
|
30
|
-
for i in range(max(0, current_line_index - 10), current_line_index):
|
31
|
-
context_lines.append(lines[i].text)
|
32
|
-
|
33
|
-
# Get the current line
|
34
|
-
current_line = lines[current_line_index]
|
35
|
-
context_lines.append(current_line.text)
|
36
|
-
|
37
|
-
#Get the next 10 lines (or fewer if at the end)
|
38
|
-
for i in range(current_line_index + 1, min(current_line_index + 11, len(lines))):
|
39
|
-
context_lines.append(lines[i].text)
|
40
|
-
|
41
|
-
ai_config = get_config().ai
|
42
|
-
|
43
|
-
#this is ugly, but prettier in the output... so idk
|
44
|
-
if ai_config.use_canned_translation_prompt:
|
45
|
-
prompt_to_use = \
|
46
|
-
f"""
|
47
|
-
Translate the following Japanese dialogue from the game {game_title} into natural, context-aware English. Focus on preserving the tone, intent, and emotional nuance of the original text, paying close attention to the context provided by surrounding lines. The dialogue may include slang, idioms, implied meanings, or game-specific terminology that should be adapted naturally for English-speaking players. Ensure the translation feels immersive and aligns with the game's narrative style and character voices.
|
48
|
-
Translate only the specified line below, providing a single result. Do not include additional text, explanations, or other lines unless explicitly requested. Allow expletives if more natural. Allow HTML tags for emphasis, italics, and other formatting as needed. Please also try to preserve existing HTML tags from the specified sentence if appropriate.
|
49
|
-
|
50
|
-
Line to Translate:
|
51
|
-
"""
|
52
|
-
elif ai_config.use_canned_context_prompt:
|
53
|
-
prompt_to_use = \
|
54
|
-
f"""
|
55
|
-
Provide a very brief summary of the scene in English based on the provided Japanese dialogue and context. Focus on the characters' actions and the immediate situation being described.
|
56
|
-
|
57
|
-
Current Sentence:
|
58
|
-
"""
|
59
|
-
else:
|
60
|
-
prompt_to_use = ai_config.custom_prompt
|
61
|
-
|
62
|
-
|
63
|
-
prompt = \
|
64
|
-
f"""
|
65
|
-
Dialogue Context:
|
66
|
-
|
67
|
-
{chr(10).join(context_lines)}
|
68
|
-
|
69
|
-
I am playing the game {game_title}. With that, and the above dialogue context in mind, answer the following prompt.
|
70
|
-
|
71
|
-
{prompt_to_use}
|
72
|
-
|
73
|
-
{sentence}
|
74
|
-
"""
|
75
|
-
|
76
|
-
logger.debug(prompt)
|
77
|
-
try:
|
78
|
-
response = model.generate_content(prompt)
|
79
|
-
return response.text.strip()
|
80
|
-
except Exception as e:
|
81
|
-
return f"Translation failed: {e}"
|
82
|
-
|
83
|
-
# Example Usage: Zero Escape: 999 examples
|
84
|
-
|
85
|
-
# zero_escape_dialogue1 = [
|
86
|
-
# "扉は開いた…?",
|
87
|
-
# "まさか、こんな仕掛けが…",
|
88
|
-
# "一体、何が起こっているんだ?",
|
89
|
-
# "この数字の意味は…?",
|
90
|
-
# "落ち着いて、考えるんだ。",
|
91
|
-
# "でも、時間が…",
|
92
|
-
# "まだ、諦めるな!",
|
93
|
-
# "一体、誰が…?",
|
94
|
-
# "まさか、あの人が…?",
|
95
|
-
# "もう、ダメだ…",
|
96
|
-
# "まだ、希望はある!",
|
97
|
-
# "この部屋から、脱出するんだ!",
|
98
|
-
# "でも、どうやって…?",
|
99
|
-
# "何か、手がかりがあるはずだ!",
|
100
|
-
# "早く、見つけないと…",
|
101
|
-
# ]
|
102
|
-
#
|
103
|
-
#
|
104
|
-
# current_line_index = 3
|
105
|
-
# translation = translate_with_context(zero_escape_dialogue1, current_line_index, "Zero Escape: 999")
|
106
|
-
# print(f"Original: {zero_escape_dialogue1[current_line_index]}")
|
107
|
-
# print(f"Translation: {translation}")
|
108
|
-
#
|
109
|
-
# # Example with fewer context lines at the beginning.
|
110
|
-
# zero_escape_dialogue2 = [
|
111
|
-
# "このアミュレット…",
|
112
|
-
# "何かを感じる…",
|
113
|
-
# "この数字は…",
|
114
|
-
# "9…?",
|
115
|
-
# "まさか、これは…",
|
116
|
-
# "何かの手がかり…?",
|
117
|
-
# "急がないと…",
|
118
|
-
# "時間がない…",
|
119
|
-
# "早く、脱出を…",
|
120
|
-
# ]
|
121
|
-
#
|
122
|
-
# current_line_index = 3
|
123
|
-
# translation = translate_with_context(zero_escape_dialogue2, current_line_index, "Zero Escape: 999")
|
124
|
-
# print(f"Original: {zero_escape_dialogue2[current_line_index]}")
|
125
|
-
# print(f"Translation: {translation}")
|
126
|
-
#
|
127
|
-
# #example with fewer context lines at the end.
|
128
|
-
# zero_escape_dialogue3 = [
|
129
|
-
# "この状況、理解できない。",
|
130
|
-
# "誰かが、私たちを閉じ込めたのか?",
|
131
|
-
# "なぜ、こんなことを…?",
|
132
|
-
# "このゲームの目的は…?",
|
133
|
-
# "一体、何が真実なんだ?",
|
134
|
-
# "信じられるのは、誰…?",
|
135
|
-
# "疑心暗鬼になるな。",
|
136
|
-
# "でも、どうすれば…?",
|
137
|
-
# "とにかく、進むしかない。"
|
138
|
-
# ]
|
139
|
-
#
|
140
|
-
# current_line_index = 4
|
141
|
-
# translation = translate_with_context(zero_escape_dialogue3, current_line_index, "Zero Escape: 999")
|
142
|
-
# print(f"Original: {zero_escape_dialogue3[current_line_index]}")
|
143
|
-
# print(f"Translation: {translation}")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|