GameSentenceMiner 2.19.10__py3-none-any.whl → 2.19.12__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.
@@ -213,13 +213,17 @@ class OpenAIManager(AIManager):
213
213
  text_output = response.choices[0].message.content.strip()
214
214
  # get the json at the end of the message
215
215
  if "{" in text_output and "}" in text_output:
216
- json_output = text_output[text_output.find(
217
- "{"):text_output.rfind("}")+1]
218
- text_output = json.loads(json_output)['output']
216
+ try:
217
+ json_output = text_output[text_output.find(
218
+ "{"):text_output.rfind("}")+1]
219
+ json_output = json_output.replace("{output:", '{"output":')
220
+ text_output = json.loads(json_output)['output']
221
+ except Exception as e:
222
+ self.logger.debug(f"Failed to parse JSON from response returning response raw: {e}", exc_info=True)
219
223
  # self.logger.debug(f"Received response:\n{text_output}")
220
224
  return text_output
221
225
  except Exception as e:
222
- self.logger.error(f"OpenAI processing failed: {e}")
226
+ self.logger.error(f"OpenAI processing failed: {e}", exc_info=True)
223
227
  return f"Processing failed: {e}"
224
228
 
225
229
 
GameSentenceMiner/anki.py CHANGED
@@ -376,12 +376,13 @@ def fix_overlay_whitespace(last_note: AnkiCard, note, lines=None):
376
376
  return note, last_note
377
377
 
378
378
 
379
- def get_initial_card_info(last_note: AnkiCard, selected_lines):
379
+ def get_initial_card_info(last_note: AnkiCard, selected_lines, game_line: GameLine):
380
380
  note = {'id': last_note.noteId, 'fields': {}}
381
381
  if not last_note:
382
382
  return note, last_note
383
383
  note, last_note = fix_overlay_whitespace(last_note, note, selected_lines)
384
- game_line = get_text_event(last_note)
384
+ if not game_line:
385
+ game_line = get_text_event(last_note)
385
386
  sentences = []
386
387
  sentences_text = ''
387
388
 
@@ -597,7 +598,7 @@ def update_card_from_same_sentence(last_card, lines, game_line):
597
598
  return
598
599
 
599
600
  if anki_result.success:
600
- note, last_card = get_initial_card_info(last_card, lines)
601
+ note, last_card = get_initial_card_info(last_card, lines, game_line)
601
602
  tango = last_card.get_field(get_config().anki.word_field)
602
603
  update_anki_card(last_card, note=note,
603
604
  game_line=get_mined_line(last_card, lines), use_existing_files=True, tango=tango)
GameSentenceMiner/gsm.py CHANGED
@@ -203,7 +203,7 @@ class VideoToAudioHandler(FileSystemEventHandler):
203
203
  last_note = anki.get_last_anki_card()
204
204
 
205
205
  note, last_note = anki.get_initial_card_info(
206
- last_note, selected_lines)
206
+ last_note, selected_lines, game_line=mined_line)
207
207
  tango = last_note.get_field(
208
208
  get_config().anki.word_field) if last_note else ''
209
209
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.19.10
3
+ Version: 2.19.12
4
4
  Summary: A tool for mining sentences from games. Update: Dependencies, replay buffer based line searching, and bug fixes.
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -1,11 +1,11 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- GameSentenceMiner/anki.py,sha256=5hp5WsNp7spazjQF9rZrNzOoQ2ZPFIl2sTdU5oDSWRE,29924
2
+ GameSentenceMiner/anki.py,sha256=SvmkL-7AqMKtCWfgwyxALvEHBOoxmQabi_uSYahf5nU,29982
3
3
  GameSentenceMiner/gametext.py,sha256=4PPm7QSWDmvsyooVjFANkd1Vnoy5ixbGRMHfYfhwGs0,13320
4
- GameSentenceMiner/gsm.py,sha256=dg41VMDLzR3U8-Xm1oHGfU2JKL8cyH-WacqY6tLrWyM,36164
4
+ GameSentenceMiner/gsm.py,sha256=N4m3tqesHkwkgLeOAlBvzwCYiy2INNZ85maZWCdglUM,36186
5
5
  GameSentenceMiner/obs.py,sha256=UB4_OJ-vZQbHyuupB8JmwhSFdYyQX_5f5TpRXU1D7Kk,43300
6
6
  GameSentenceMiner/vad.py,sha256=iMSsoUZ7-aNoWKzDKfOHdB3Zk5U2hV7x5hqTny6rj08,21501
7
7
  GameSentenceMiner/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- GameSentenceMiner/ai/ai_prompting.py,sha256=mq9Odv_FpohXagU-OoSZbLWttdrEl1M1NiqnodeUpD8,29126
8
+ GameSentenceMiner/ai/ai_prompting.py,sha256=pjhNMcCjYLfmOz3n9IPFtKTkvFDBbQXsXwT5-vAhrBY,29429
9
9
  GameSentenceMiner/assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  GameSentenceMiner/assets/icon.png,sha256=9GRL8uXUAgkUSlvbm9Pv9o2poFVRGdW6s2ub_DeUD9M,937624
11
11
  GameSentenceMiner/assets/icon128.png,sha256=l90j7biwdz5ahwOd5wZ-406ryEV9Pan93dquJQ3e1CI,18395
@@ -135,9 +135,9 @@ GameSentenceMiner/web/templates/components/kanji_grid/thousand_character_classic
135
135
  GameSentenceMiner/web/templates/components/kanji_grid/wanikani_levels.json,sha256=8wjnnaYQqmho6t5tMxrIAc03512A2tYhQh5dfsQnfAM,11372
136
136
  GameSentenceMiner/web/templates/components/kanji_grid/words_hk_frequency_list.json,sha256=wRkqZNPzz6DT9OTPHpXwfqW96Qb96stCQNNgOL-ZdKk,17535
137
137
  GameSentenceMiner/wip/__init___.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
138
- gamesentenceminer-2.19.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
139
- gamesentenceminer-2.19.10.dist-info/METADATA,sha256=EhqseprTQY7un78Qu-PUZsLehPILBcKMlJIVwiikvAk,8181
140
- gamesentenceminer-2.19.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
141
- gamesentenceminer-2.19.10.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
142
- gamesentenceminer-2.19.10.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
143
- gamesentenceminer-2.19.10.dist-info/RECORD,,
138
+ gamesentenceminer-2.19.12.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
139
+ gamesentenceminer-2.19.12.dist-info/METADATA,sha256=Pjz-4py4DFrG1qHv_igp7J56UK0E8M6fvLKcSuM4lkw,8181
140
+ gamesentenceminer-2.19.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
141
+ gamesentenceminer-2.19.12.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
142
+ gamesentenceminer-2.19.12.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
143
+ gamesentenceminer-2.19.12.dist-info/RECORD,,