Commit 4fcd3b84 authored by dmMaze's avatar dmMaze
Browse files

fix #258

parent 0c4e98bd
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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
+2 −5
Original line number Diff line number Diff line
@@ -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: