Loading ui/keywordsubwidget.py +2 −5 Original line number Diff line number Diff line Loading @@ -121,14 +121,11 @@ class KeywordSubWidget(Widget): flag |= re.IGNORECASE if not subpair['use_reg']: regexr = re.escape(regexr) try: pattern = re.compile(regexr, flag) text = pattern.sub(subpair['sub'], text) text = re.sub(regexr, subpair['sub'], text) except Exception as e: LOGGER.error(f'Invalid regex expression at line {ii}:') LOGGER.error(traceback.format_exc()) continue # print(f'k: {k}, {text}') # print('text: ', text) return text No newline at end of file ui/mainwindow.py +2 −5 Original line number Diff line number Diff line Loading @@ -1114,11 +1114,8 @@ class MainWindow(FramelessWindow): def ocr_postprocess(self, textblocks: List[TextBlock], img, ocr_module=None, **kwargs): for blk in textblocks: if isinstance(blk.text, List): for ii, t in enumerate(blk.text): blk.text[ii] = self.ocrSubWidget.sub_text(t) else: blk.text = self.ocrSubWidget.sub_text(blk.text) text = blk.get_text() blk.text = self.ocrSubWidget.sub_text(text) def translate_postprocess(self, translations: List[str] = None, textblocks: List[TextBlock] = None, translator = None): if not self.postprocess_mt_toggle: Loading Loading
ui/keywordsubwidget.py +2 −5 Original line number Diff line number Diff line Loading @@ -121,14 +121,11 @@ class KeywordSubWidget(Widget): flag |= re.IGNORECASE if not subpair['use_reg']: regexr = re.escape(regexr) try: pattern = re.compile(regexr, flag) text = pattern.sub(subpair['sub'], text) text = re.sub(regexr, subpair['sub'], text) except Exception as e: LOGGER.error(f'Invalid regex expression at line {ii}:') LOGGER.error(traceback.format_exc()) continue # print(f'k: {k}, {text}') # print('text: ', text) return text No newline at end of file
ui/mainwindow.py +2 −5 Original line number Diff line number Diff line Loading @@ -1114,11 +1114,8 @@ class MainWindow(FramelessWindow): def ocr_postprocess(self, textblocks: List[TextBlock], img, ocr_module=None, **kwargs): for blk in textblocks: if isinstance(blk.text, List): for ii, t in enumerate(blk.text): blk.text[ii] = self.ocrSubWidget.sub_text(t) else: blk.text = self.ocrSubWidget.sub_text(blk.text) text = blk.get_text() blk.text = self.ocrSubWidget.sub_text(text) def translate_postprocess(self, translations: List[str] = None, textblocks: List[TextBlock] = None, translator = None): if not self.postprocess_mt_toggle: Loading