GameSentenceMiner 2.5.1__py3-none-any.whl → 2.5.3__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 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 = "".join([line.text for line in selected_lines])
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: {remove_html_and_cloze_tags(sentence_in_anki)}, {sentences}, {remove_html_and_cloze_tags(sentence_in_anki) in sentences}")
129
- sentences = sentences.replace(remove_html_and_cloze_tags(sentence_in_anki), sentence_in_anki)
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):
@@ -174,8 +191,14 @@ def get_last_anki_card() -> AnkiCard | dict:
174
191
  added_ids = invoke('findNotes', query='added:1')
175
192
  if not added_ids:
176
193
  return {}
177
- last_note = AnkiCard.from_dict(invoke('notesInfo', notes=[added_ids[-1]])[0])
178
- return last_note
194
+
195
+ card_dict = invoke('notesInfo', notes=[added_ids[-1]])[0]
196
+ try:
197
+ return AnkiCard.from_dict(card_dict)
198
+ except Exception as e:
199
+ logger.error(f"Error fetching last card: {e}")
200
+ logger.info(card_dict)
201
+ raise e
179
202
 
180
203
 
181
204
  def add_wildcards(expression):
@@ -88,11 +88,8 @@ class SceneItemsResponse:
88
88
  @dataclass
89
89
  class AnkiCard:
90
90
  noteId: int
91
- profile: str
92
91
  tags: list[str]
93
92
  fields: dict[str, dict[str, str]]
94
- modelName: str
95
- mod: int
96
93
  cards: list[int]
97
94
  alternatives = {
98
95
  "word_field": ["Front", "Word", "TargetWord", "Expression"],
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
+
@@ -150,6 +150,7 @@ class UtilityApp:
150
150
  # for checkbox in self.checkboxes:
151
151
  # checkbox.set(False)
152
152
 
153
+
153
154
  def init_utility_window(root):
154
155
  global utility_window
155
156
  utility_window = UtilityApp(root)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.5.1
3
+ Version: 2.5.3
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
@@ -1,17 +1,17 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- GameSentenceMiner/anki.py,sha256=_jr6q3tOSP-7YGaY9cVz5v3508T_V2JINJjDYbp1YS0,11495
2
+ GameSentenceMiner/anki.py,sha256=1VoWT1f5u98eYbXK7U4l8wpg_uL1nBPviNg4Q1YTCBg,12231
3
3
  GameSentenceMiner/config_gui.py,sha256=PzzLX-OwK71U5JSFaxup0ec0oWBWaF6AeCXs0m13HK0,56762
4
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
8
8
  GameSentenceMiner/gsm.py,sha256=cWHJwWHyKsdzo0TXTXREG549MUtlQLyect9S37UK56g,20309
9
- GameSentenceMiner/model.py,sha256=WYLjIS9IEPxaLPwG5c-edfcfBKYzBFpdR3V3Da8MuLg,5277
9
+ GameSentenceMiner/model.py,sha256=bZm-2vkIw4gQCGLB02eDoTtO1Ymb_dnHk0VDJDFO3y8,5228
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=nmp2cmuBN0Azoc91f3zN_dZSh4nK9z21VTfpIbn8Tk4,4761
14
- GameSentenceMiner/utility_gui.py,sha256=VYuY8Br47AFak_zOVx9R1oUCBvoRjonDyE0oE6FVwJ0,5742
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.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
23
- gamesentenceminer-2.5.1.dist-info/METADATA,sha256=OjwqqaJ_DG7FR6OLc3z1XlUX6WH6SqsOc4EDXUjbzbQ,5409
24
- gamesentenceminer-2.5.1.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
25
- gamesentenceminer-2.5.1.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
26
- gamesentenceminer-2.5.1.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
27
- gamesentenceminer-2.5.1.dist-info/RECORD,,
22
+ gamesentenceminer-2.5.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
23
+ gamesentenceminer-2.5.3.dist-info/METADATA,sha256=2FyxGIwSYPDNPlftNrNUJ5T16irg35zuZFhqn3bdIq4,5409
24
+ gamesentenceminer-2.5.3.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
25
+ gamesentenceminer-2.5.3.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
26
+ gamesentenceminer-2.5.3.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
27
+ gamesentenceminer-2.5.3.dist-info/RECORD,,