GameSentenceMiner 2.7.11__py3-none-any.whl → 2.7.13__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.
@@ -126,8 +126,6 @@ def get_ocr_config() -> OCRConfig:
126
126
  return OCRConfig.from_dict(new_config_data)
127
127
  elif "rectangles" in config_data and isinstance(config_data["rectangles"], list) and all(
128
128
  isinstance(item, dict) and "coordinates" in item for item in config_data["rectangles"]):
129
- logger.info("Loading new OCR config format.")
130
- logger.info(config_data)
131
129
  return OCRConfig.from_dict(config_data)
132
130
  else:
133
131
  raise Exception(f"Invalid config format in {config_path}.")
@@ -210,11 +208,6 @@ rectangles = None
210
208
  def do_second_ocr(ocr1_text, rectangle_index, time, img):
211
209
  global twopassocr, ocr2, last_ocr1_results, last_ocr2_results
212
210
  last_result = ([], -1)
213
-
214
- previous_ocr1_text = last_ocr1_results[rectangle_index]
215
- if fuzz.ratio(previous_ocr1_text, ocr1_text) >= 80:
216
- logger.info("Seems like the same text, not doing 2nd pass")
217
- last_ocr1_results[rectangle_index] = ocr1_text
218
211
  try:
219
212
  orig_text, text = run.process_and_write_results(img, None, None, last_result, TextFiltering(),
220
213
  engine=ocr2)
@@ -222,6 +215,7 @@ def do_second_ocr(ocr1_text, rectangle_index, time, img):
222
215
  if fuzz.ratio(previous_ocr2_text, text) >= 80:
223
216
  logger.info("Seems like the same text from previous ocr2 result, not sending")
224
217
  return
218
+ img.save(os.path.join(get_app_directory(), "temp", "last_successful_ocr.png"))
225
219
  last_ocr2_results[rectangle_index] = text
226
220
  if get_config().advanced.ocr_sends_to_clipboard:
227
221
  import pyperclip
@@ -244,7 +238,7 @@ def text_callback(text, rectangle_index, time, img=None):
244
238
 
245
239
  current_time = time if time else datetime.now()
246
240
 
247
- previous_text = last_oneocr_results_to_check.get(rectangle_index, "")
241
+ previous_text = last_oneocr_results_to_check.get(rectangle_index, "").strip()
248
242
 
249
243
  if not text:
250
244
  if previous_text:
@@ -253,15 +247,19 @@ def text_callback(text, rectangle_index, time, img=None):
253
247
  if twopassocr:
254
248
  do_second_ocr(previous_text, rectangle_index, time, img)
255
249
  else:
256
- previous_text = last_ocr1_results[rectangle_index]
257
- if fuzz.ratio(previous_text, text) >= 80:
250
+ previous_result = last_ocr1_results[rectangle_index]
251
+ if previous_result and fuzz.ratio(previous_result, previous_text) >= 80:
258
252
  logger.info("Seems like the same text, not sending")
253
+ return
259
254
  if get_config().advanced.ocr_sends_to_clipboard:
260
255
  import pyperclip
261
256
  pyperclip.copy(text)
262
257
  websocket_server_thread.send_text(previous_text, stable_time)
258
+ img.save(os.path.join(get_app_directory(), "temp", "last_successful_ocr.png"))
259
+ last_ocr1_results[rectangle_index] = previous_text
263
260
  del text_stable_start_times[rectangle_index]
264
261
  del last_oneocr_results_to_check[rectangle_index]
262
+ return
265
263
  return
266
264
 
267
265
  if rectangle_index not in last_oneocr_results_to_check:
@@ -285,13 +283,13 @@ def text_callback(text, rectangle_index, time, img=None):
285
283
  done = False
286
284
 
287
285
 
288
- def run_oneocr(ocr_config: OCRConfig, i):
286
+ def run_oneocr(ocr_config: OCRConfig, i, area=False):
289
287
  global done
290
288
  rect_config = ocr_config.rectangles[i]
291
289
  coords = rect_config.coordinates
292
290
  monitor_config = rect_config.monitor
293
- exclusions = (rect.coordinates for rect in list(filter(lambda x: x.is_excluded, ocr_config.rectangles)))
294
- screen_area = ",".join(str(c) for c in coords)
291
+ exclusions = list(rect.coordinates for rect in list(filter(lambda x: x.is_excluded, ocr_config.rectangles)))
292
+ screen_area = ",".join(str(c) for c in coords) if area else None
295
293
  run.run(read_from="screencapture", write_to="callback",
296
294
  screen_capture_area=screen_area,
297
295
  # screen_capture_monitor=monitor_config['index'],
@@ -328,19 +326,21 @@ if __name__ == "__main__":
328
326
  logger.info(f"Received arguments: ocr1={ocr1}, ocr2={ocr2}, twopassocr={twopassocr}")
329
327
  global ocr_config
330
328
  ocr_config: OCRConfig = get_ocr_config()
329
+
330
+ logger.info(f"Starting OCR with configuration: Window: {ocr_config.window}, Rectangles: {len(ocr_config.rectangles)}, Engine 1: {ocr1}, Engine 2: {ocr2}, Two-pass OCR: {twopassocr}")
331
331
  if ocr_config and ocr_config.rectangles:
332
- rectangles = ocr_config.rectangles
332
+ rectangles = list(filter(lambda rect: not rect.is_excluded, ocr_config.rectangles))
333
333
  last_ocr1_results = [""] * len(rectangles) if rectangles else [""]
334
334
  last_ocr2_results = [""] * len(rectangles) if rectangles else [""]
335
335
  oneocr_threads = []
336
336
  run.init_config(False)
337
337
  if rectangles:
338
338
  for i, rectangle in enumerate(rectangles):
339
- thread = threading.Thread(target=run_oneocr, args=(ocr_config, i,), daemon=True)
339
+ thread = threading.Thread(target=run_oneocr, args=(ocr_config, i,True, ), daemon=True)
340
340
  oneocr_threads.append(thread)
341
341
  thread.start()
342
342
  else:
343
- single_ocr_thread = threading.Thread(target=run_oneocr, args=(ocr_config, 0,), daemon=True)
343
+ single_ocr_thread = threading.Thread(target=run_oneocr, args=(ocr_config, 0,False, ), daemon=True)
344
344
  oneocr_threads.append(single_ocr_thread)
345
345
  single_ocr_thread.start()
346
346
  websocket_server_thread = WebsocketServerThread(read=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.7.11
3
+ Version: 2.7.13
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,5 +1,5 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- GameSentenceMiner/anki.py,sha256=9E9GRR2zylW3Gp4PNlwYS_Nn-mhojZkjFqfYlTazte8,14068
2
+ GameSentenceMiner/anki.py,sha256=X16RG3qXUogyKwdc_T5Dugq2J4gaslpgnKbZKoggAxc,14198
3
3
  GameSentenceMiner/config_gui.py,sha256=-1PanqdtTKiwItxeyt0piXrWo7lGMWwrC4iSo4NiPz4,67521
4
4
  GameSentenceMiner/configuration.py,sha256=TGDgI93J0jVYRlV6rXXnoRFJXaWQ3_o4_OTcXUZHrZw,20405
5
5
  GameSentenceMiner/electron_config.py,sha256=dGcPYCISPehXubYSzsDuI2Gl092MYK0u3bTnkL9Jh1Y,9787
@@ -8,7 +8,7 @@ GameSentenceMiner/gametext.py,sha256=AAke4swwmN16da0IpyL5xMhU23nTz_c6z2kMfXPYv-8
8
8
  GameSentenceMiner/gsm.py,sha256=dT9MsD_uOSFdZxi50EBsfpaqOJys36T2yzBrCeakn9E,24690
9
9
  GameSentenceMiner/model.py,sha256=JdnkT4VoPOXmOpRgFdvERZ09c9wLN6tUJxdrKlGZcqo,5305
10
10
  GameSentenceMiner/notification.py,sha256=FY39ChSRK0Y8TQ6lBGsLnpZUFPtFpSy2tweeXVoV7kc,2809
11
- GameSentenceMiner/obs.py,sha256=3h1hh868zdXQFGXJ7_mQZs5kcudEMa3yBOrbCVckhCs,9139
11
+ GameSentenceMiner/obs.py,sha256=UuMGhiD1sinEjM2JGdLLeQAXTifYPrcNy-78Ta316ds,9022
12
12
  GameSentenceMiner/package.py,sha256=YlS6QRMuVlm6mdXx0rlXv9_3erTGS21jaP3PNNWfAH0,1250
13
13
  GameSentenceMiner/util.py,sha256=W49gqYlhbzZe-17zHMFcAjNeeteXrv_USHT7aBDKSqM,6825
14
14
  GameSentenceMiner/utility_gui.py,sha256=JcNjk9Wrz_Au7P4ITslSBqXBU-o6nA2sc2vJvglAk4o,7432
@@ -21,10 +21,10 @@ GameSentenceMiner/downloader/Untitled_json.py,sha256=RUUl2bbbCpUDUUS0fP0tdvf5Fng
21
21
  GameSentenceMiner/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  GameSentenceMiner/downloader/download_tools.py,sha256=mI1u_FGBmBqDIpCH3jOv8DOoZ3obgP5pIf9o9SVfX2Q,8131
23
23
  GameSentenceMiner/ocr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- GameSentenceMiner/ocr/gsm_ocr_config.py,sha256=FZ3CCgtpVawJ2mq3EP0KheJjYte5PlyOO1VnGND-__Y,467
24
+ GameSentenceMiner/ocr/gsm_ocr_config.py,sha256=zagsB4UD9mmZX_r6dFBCXZqdDa0XGk-RvIqbKoPB9lQ,1932
25
25
  GameSentenceMiner/ocr/ocrconfig.py,sha256=hTROOZ3On2HngXKxwQFZvnr5AxlmlMV0mPxv-F3NbMg,6476
26
- GameSentenceMiner/ocr/owocr_area_selector.py,sha256=MggSnJSUQhs7SD6YTKRNnVhEZEliLgaUTOPkBUCjAss,11952
27
- GameSentenceMiner/ocr/owocr_helper.py,sha256=RMoGmmD9ECR_sFxWl-kxRPiYaNOk8SJVPSwhDBIkS-4,14825
26
+ GameSentenceMiner/ocr/owocr_area_selector.py,sha256=bCgusYXe9ibCsf56PlU301aNfDA2PDKasi78ox0IGbk,46856
27
+ GameSentenceMiner/ocr/owocr_helper.py,sha256=Rd1wcVtJy0N6ySn1p7-08hLYA9iPkts12zGJESoEewI,15126
28
28
  GameSentenceMiner/owocr/owocr/__init__.py,sha256=opjBOyGGyEqZCE6YdZPnyt7nVfiwyELHsXA0jAsjm14,25
29
29
  GameSentenceMiner/owocr/owocr/__main__.py,sha256=r8MI6RAmbkTWqOJ59uvXoDS7CSw5jX5war9ULGWELrA,128
30
30
  GameSentenceMiner/owocr/owocr/config.py,sha256=738QCJHEWpFhMh966plOcXYWwcshSiRsxjjIwldeTtI,7461
@@ -36,9 +36,9 @@ GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
36
36
  GameSentenceMiner/vad/silero_trim.py,sha256=ULf3zwS-JMsY82cKF7gZxREHw8L6lgpWF2U1YqgE9Oc,1681
37
37
  GameSentenceMiner/vad/vosk_helper.py,sha256=125X8C9NxFPlWWpoNsbOnEqKx8RCjXN109zNx_QXhyg,6070
38
38
  GameSentenceMiner/vad/whisper_helper.py,sha256=JJ-iltCh813XdjyEw0Wn5DaErf6PDqfH0Efu1Md8cIY,3543
39
- gamesentenceminer-2.7.11.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
40
- gamesentenceminer-2.7.11.dist-info/METADATA,sha256=HKYJ4gjLwMKl43qNewCIV1-ykumK2lYIjgPbl-KhPAQ,5840
41
- gamesentenceminer-2.7.11.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
42
- gamesentenceminer-2.7.11.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
43
- gamesentenceminer-2.7.11.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
44
- gamesentenceminer-2.7.11.dist-info/RECORD,,
39
+ gamesentenceminer-2.7.13.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
40
+ gamesentenceminer-2.7.13.dist-info/METADATA,sha256=O0-SbnS2VsaCS9Erd-r0ufjQqly71axdeILxm4k61LE,5840
41
+ gamesentenceminer-2.7.13.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
42
+ gamesentenceminer-2.7.13.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
43
+ gamesentenceminer-2.7.13.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
44
+ gamesentenceminer-2.7.13.dist-info/RECORD,,