GameSentenceMiner 2.5.0__py3-none-any.whl → 2.5.2__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/anki.py +24 -6
- GameSentenceMiner/configuration.py +1 -1
- GameSentenceMiner/util.py +32 -0
- GameSentenceMiner/utility_gui.py +43 -12
- {gamesentenceminer-2.5.0.dist-info → gamesentenceminer-2.5.2.dist-info}/METADATA +3 -2
- {gamesentenceminer-2.5.0.dist-info → gamesentenceminer-2.5.2.dist-info}/RECORD +10 -10
- {gamesentenceminer-2.5.0.dist-info → gamesentenceminer-2.5.2.dist-info}/WHEEL +1 -1
- {gamesentenceminer-2.5.0.dist-info → gamesentenceminer-2.5.2.dist-info}/entry_points.txt +0 -0
- {gamesentenceminer-2.5.0.dist-info → gamesentenceminer-2.5.2.dist-info/licenses}/LICENSE +0 -0
- {gamesentenceminer-2.5.0.dist-info → gamesentenceminer-2.5.2.dist-info}/top_level.txt +0 -0
GameSentenceMiner/anki.py
CHANGED
@@ -15,7 +15,7 @@ from GameSentenceMiner.gametext import get_text_event
|
|
15
15
|
from GameSentenceMiner.model import AnkiCard
|
16
16
|
from GameSentenceMiner.utility_gui import utility_window, get_utility_window
|
17
17
|
from GameSentenceMiner.obs import get_current_game
|
18
|
-
from GameSentenceMiner.util import remove_html_and_cloze_tags
|
18
|
+
from GameSentenceMiner.util import remove_html_and_cloze_tags, combine_dialogue
|
19
19
|
|
20
20
|
audio_in_anki = None
|
21
21
|
screenshot_in_anki = None
|
@@ -122,15 +122,32 @@ def get_initial_card_info(last_note: AnkiCard, selected_lines):
|
|
122
122
|
game_line = get_text_event(last_note)
|
123
123
|
|
124
124
|
if selected_lines and get_config().anki.multi_overwrites_sentence:
|
125
|
-
sentences =
|
125
|
+
sentences = []
|
126
|
+
sentences_text = ''
|
126
127
|
try:
|
127
128
|
sentence_in_anki = last_note.get_field(get_config().anki.sentence_field)
|
128
|
-
logger.info(f"Attempting Preserve HTML for multi-line
|
129
|
-
|
129
|
+
logger.info(f"Attempting Preserve HTML for multi-line")
|
130
|
+
for line in selected_lines:
|
131
|
+
if remove_html_and_cloze_tags(sentence_in_anki) in line.text:
|
132
|
+
sentences.append(sentence_in_anki)
|
133
|
+
logger.info("Found matching line in Anki, Preserving HTML!")
|
134
|
+
else:
|
135
|
+
sentences.append(line.text)
|
136
|
+
|
137
|
+
logger.info(f"Attempting to Fix Character Dialogue Format")
|
138
|
+
logger.info([f"'{line.text}'" for line in selected_lines])
|
139
|
+
try:
|
140
|
+
combined_lines = combine_dialogue(sentences)
|
141
|
+
|
142
|
+
if combined_lines:
|
143
|
+
sentences = "".join(combined_lines)
|
144
|
+
except Exception as e:
|
145
|
+
logger.debug(f'Error combining dialogue: {e}, defaulting')
|
146
|
+
pass
|
130
147
|
except Exception as e:
|
131
148
|
logger.debug(f"Error preserving HTML for multi-line: {e}")
|
132
149
|
pass
|
133
|
-
note['fields'][get_config().anki.sentence_field] = sentences
|
150
|
+
note['fields'][get_config().anki.sentence_field] = sentences_text if sentences_text else "<br>".join(sentences)
|
134
151
|
|
135
152
|
if get_config().anki.previous_sentence_field and game_line.prev and not \
|
136
153
|
last_note.get_field(get_config().anki.previous_sentence_field):
|
@@ -233,8 +250,9 @@ def update_new_card():
|
|
233
250
|
if get_config().obs.get_game_from_scene:
|
234
251
|
obs.update_current_game()
|
235
252
|
if use_prev_audio:
|
253
|
+
lines = get_utility_window().get_selected_lines()
|
236
254
|
with util.lock:
|
237
|
-
update_anki_card(last_card, note=get_initial_card_info(last_card,
|
255
|
+
update_anki_card(last_card, note=get_initial_card_info(last_card, lines), reuse_audio=True)
|
238
256
|
else:
|
239
257
|
logger.info("New card(s) detected! Added to Processing Queue!")
|
240
258
|
card_queue.append(last_card)
|
GameSentenceMiner/util.py
CHANGED
@@ -146,3 +146,35 @@ def is_windows():
|
|
146
146
|
def remove_html_and_cloze_tags(text):
|
147
147
|
text = re.sub(r'<.*?>', '', re.sub(r'{{c\d+::(.*?)(::.*?)?}}', r'\1', text))
|
148
148
|
return text
|
149
|
+
|
150
|
+
|
151
|
+
def combine_dialogue(dialogue_lines, new_lines=None):
|
152
|
+
if not dialogue_lines: # Handle empty input
|
153
|
+
return []
|
154
|
+
|
155
|
+
if new_lines is None:
|
156
|
+
new_lines = []
|
157
|
+
|
158
|
+
if '「' not in dialogue_lines[0]:
|
159
|
+
new_lines.append(dialogue_lines[0] + "<br>")
|
160
|
+
return new_lines
|
161
|
+
|
162
|
+
character_name = dialogue_lines[0].split("「")[0]
|
163
|
+
text = character_name + "「"
|
164
|
+
next_character = ''
|
165
|
+
|
166
|
+
for i, line in enumerate(dialogue_lines):
|
167
|
+
if not line.startswith(character_name + "「"):
|
168
|
+
text = text + "」<br>"
|
169
|
+
next_character = line.split("「")[0]
|
170
|
+
new_lines.append(text)
|
171
|
+
new_lines.extend(combine_dialogue(dialogue_lines[i:]))
|
172
|
+
break
|
173
|
+
else:
|
174
|
+
text += ("<br>" if i > 0 else "") + line.split("「")[1].rstrip("」") + ""
|
175
|
+
else:
|
176
|
+
text = text + "」"
|
177
|
+
new_lines.append(text)
|
178
|
+
|
179
|
+
return new_lines
|
180
|
+
|
GameSentenceMiner/utility_gui.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
import json
|
2
|
+
import os
|
1
3
|
import tkinter as tk
|
2
4
|
from tkinter import ttk
|
3
5
|
|
4
|
-
from GameSentenceMiner.configuration import logger
|
6
|
+
from GameSentenceMiner.configuration import logger, get_app_directory
|
7
|
+
|
5
8
|
|
6
9
|
class UtilityApp:
|
7
10
|
def __init__(self, root):
|
8
11
|
self.root = root
|
9
|
-
|
10
12
|
self.items = []
|
11
13
|
self.checkboxes = []
|
12
14
|
self.multi_mine_window = None # Store the multi-mine window reference
|
@@ -14,32 +16,60 @@ class UtilityApp:
|
|
14
16
|
|
15
17
|
style = ttk.Style()
|
16
18
|
style.configure("TCheckbutton", font=("Arial", 20)) # Change the font and size
|
19
|
+
self.config_file = os.path.join(get_app_directory(), "multi-mine-window-config.json")
|
20
|
+
self.load_window_config()
|
21
|
+
|
22
|
+
|
23
|
+
def save_window_config(self):
|
24
|
+
if self.multi_mine_window:
|
25
|
+
config = {
|
26
|
+
"x": self.multi_mine_window.winfo_x(),
|
27
|
+
"y": self.multi_mine_window.winfo_y(),
|
28
|
+
"width": self.multi_mine_window.winfo_width(),
|
29
|
+
"height": self.multi_mine_window.winfo_height()
|
30
|
+
}
|
31
|
+
print(config)
|
32
|
+
with open(self.config_file, "w") as f:
|
33
|
+
json.dump(config, f)
|
34
|
+
|
35
|
+
def load_window_config(self):
|
36
|
+
if os.path.exists(self.config_file):
|
37
|
+
with open(self.config_file, "r") as f:
|
38
|
+
config = json.load(f)
|
39
|
+
self.window_x = config.get("x", 100)
|
40
|
+
self.window_y = config.get("y", 100)
|
41
|
+
self.window_width = config.get("width", 800)
|
42
|
+
self.window_height = config.get("height", 400)
|
43
|
+
else:
|
44
|
+
self.window_x = 100
|
45
|
+
self.window_y = 100
|
46
|
+
self.window_width = 800
|
47
|
+
self.window_height = 400
|
17
48
|
|
18
|
-
# def show(self):
|
19
|
-
# if self.multi_mine_window is None or not tk.Toplevel.winfo_exists(self.multi_mine_window):
|
20
|
-
# self.multi_mine_window = tk.Toplevel(self.root)
|
21
|
-
# self.multi_mine_window.title("Multi-Mine Window")
|
22
|
-
# self.update_multi_mine_window()
|
23
|
-
#
|
24
49
|
def show(self):
|
25
|
-
""" Open the multi-mine window only if it doesn't exist. """
|
26
50
|
if not self.multi_mine_window or not tk.Toplevel.winfo_exists(self.multi_mine_window):
|
27
|
-
logger.info("opening multi-mine_window")
|
28
51
|
self.multi_mine_window = tk.Toplevel(self.root)
|
29
52
|
self.multi_mine_window.title("Multi Mine Window")
|
30
53
|
|
31
|
-
self.multi_mine_window.
|
54
|
+
self.multi_mine_window.geometry(f"{self.window_width}x{self.window_height}+{self.window_x}+{self.window_y}")
|
55
|
+
|
56
|
+
self.multi_mine_window.minsize(800, 400)
|
32
57
|
|
33
58
|
self.checkbox_frame = ttk.Frame(self.multi_mine_window)
|
34
59
|
self.checkbox_frame.pack(padx=10, pady=10, fill="both", expand=True)
|
35
60
|
|
36
|
-
# Add existing items
|
37
61
|
for line, var in self.items:
|
38
62
|
self.add_checkbox_to_gui(line, var)
|
63
|
+
|
64
|
+
self.multi_mine_window.protocol("WM_DELETE_WINDOW", self.on_close)
|
39
65
|
else:
|
40
66
|
self.multi_mine_window.deiconify()
|
41
67
|
self.multi_mine_window.lift()
|
42
68
|
|
69
|
+
def on_close(self):
|
70
|
+
self.save_window_config()
|
71
|
+
self.multi_mine_window.withdraw()
|
72
|
+
|
43
73
|
def add_text(self, line):
|
44
74
|
if line.text:
|
45
75
|
var = tk.BooleanVar()
|
@@ -120,6 +150,7 @@ class UtilityApp:
|
|
120
150
|
# for checkbox in self.checkboxes:
|
121
151
|
# checkbox.set(False)
|
122
152
|
|
153
|
+
|
123
154
|
def init_utility_window(root):
|
124
155
|
global utility_window
|
125
156
|
utility_window = UtilityApp(root)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: GameSentenceMiner
|
3
|
-
Version: 2.5.
|
3
|
+
Version: 2.5.2
|
4
4
|
Summary: A tool for mining sentences from games. Update: Multi-Line Mining! Fixed!
|
5
5
|
Author-email: Beangate <bpwhelan95@gmail.com>
|
6
6
|
License: MIT License
|
@@ -32,6 +32,7 @@ Requires-Dist: dataclasses_json~=0.6.7
|
|
32
32
|
Requires-Dist: numpy
|
33
33
|
Requires-Dist: pystray
|
34
34
|
Requires-Dist: pywin32; sys_platform == "win32"
|
35
|
+
Dynamic: license-file
|
35
36
|
|
36
37
|
# Game Sentence Miner
|
37
38
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
GameSentenceMiner/anki.py,sha256=
|
2
|
+
GameSentenceMiner/anki.py,sha256=0-L2D8M69dZcanzRGAcQH2_b2yc1VCXT3rSyit8j57w,12088
|
3
3
|
GameSentenceMiner/config_gui.py,sha256=PzzLX-OwK71U5JSFaxup0ec0oWBWaF6AeCXs0m13HK0,56762
|
4
|
-
GameSentenceMiner/configuration.py,sha256=
|
4
|
+
GameSentenceMiner/configuration.py,sha256=kyvNCkZSZcqXbGjak8lb_GyhhjN8tIfb7eEfusz_M8A,16038
|
5
5
|
GameSentenceMiner/electron_messaging.py,sha256=fBk9Ipo0jg2OZwYaKe1Qsm05P2ftrdTRGgFYob7ZA-k,139
|
6
6
|
GameSentenceMiner/ffmpeg.py,sha256=2dwKbKxw_9sUXud67pPAx_6dGd1j-D99CdqLFVtbhSk,11479
|
7
7
|
GameSentenceMiner/gametext.py,sha256=LORVdE2WEo1CDI8gonc7qxrhbS4KFKXFQVKjhlkpLbc,7368
|
@@ -10,8 +10,8 @@ GameSentenceMiner/model.py,sha256=WYLjIS9IEPxaLPwG5c-edfcfBKYzBFpdR3V3Da8MuLg,52
|
|
10
10
|
GameSentenceMiner/notification.py,sha256=WeFodBsshhbOagcEfjAJ3kxjUGvBuUAQKEJ8Zf0YO04,2267
|
11
11
|
GameSentenceMiner/obs.py,sha256=8ImXAVUWa4JdzwcBOEFShlZRZzh1dCvdpD1aEGhQfbU,6566
|
12
12
|
GameSentenceMiner/package.py,sha256=YlS6QRMuVlm6mdXx0rlXv9_3erTGS21jaP3PNNWfAH0,1250
|
13
|
-
GameSentenceMiner/util.py,sha256=
|
14
|
-
GameSentenceMiner/utility_gui.py,sha256=
|
13
|
+
GameSentenceMiner/util.py,sha256=uDM1E-kNTJODm-eDELHP66uOVUUIivXzXBxr-NmeAPw,5670
|
14
|
+
GameSentenceMiner/utility_gui.py,sha256=Ox63XZnj08MezcEG8X5EYJlbHmw-bZitN3CsWgP8lLo,5743
|
15
15
|
GameSentenceMiner/downloader/Untitled_json.py,sha256=RUUl2bbbCpUDUUS0fP0tdvf5FngZ7ILdA_J5TFYAXUQ,15272
|
16
16
|
GameSentenceMiner/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
GameSentenceMiner/downloader/download_tools.py,sha256=mI1u_FGBmBqDIpCH3jOv8DOoZ3obgP5pIf9o9SVfX2Q,8131
|
@@ -19,9 +19,9 @@ GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
19
19
|
GameSentenceMiner/vad/silero_trim.py,sha256=-thDIZLuTLra3YBj7WR16Z6JeDgSpge2YuahprBvD8I,1585
|
20
20
|
GameSentenceMiner/vad/vosk_helper.py,sha256=BI_mg_qyrjNbuEJjXSUDoV0FWEtQtEOAPmrrNixnZ_8,5974
|
21
21
|
GameSentenceMiner/vad/whisper_helper.py,sha256=OF4J8TPPoKPJR1uFwrWAZ2Q7v0HJkVvNGmF8l1tACX0,3447
|
22
|
-
gamesentenceminer-2.5.
|
23
|
-
gamesentenceminer-2.5.
|
24
|
-
gamesentenceminer-2.5.
|
25
|
-
gamesentenceminer-2.5.
|
26
|
-
gamesentenceminer-2.5.
|
27
|
-
gamesentenceminer-2.5.
|
22
|
+
gamesentenceminer-2.5.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
23
|
+
gamesentenceminer-2.5.2.dist-info/METADATA,sha256=wdtFHe9Crw0k-LDyLiVb6SvsU9Retr3kI0I4XSVgQtk,5409
|
24
|
+
gamesentenceminer-2.5.2.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
|
25
|
+
gamesentenceminer-2.5.2.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
|
26
|
+
gamesentenceminer-2.5.2.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
|
27
|
+
gamesentenceminer-2.5.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|