dmMaze / BallonsTranslator

深度学习辅助漫画翻译工具, 支持一键机翻和简单的图像/文本编辑 | Yet another computer-aided comic/manga translation tool powered by deeplearning
GNU General Public License v3.0
2.48k stars 172 forks source link

Problem Google OCR #550

Open vanderalex opened 3 weeks ago

vanderalex commented 3 weeks ago

When I use Google Lens with option apply_no_uppercase it returns text like: Misère, Ils Nous Emmenent Οῦ?!!! (All First Letter Is Upper!!!)

bropines commented 3 weeks ago

(Fixed in theory) You can check by downloading and replacing the file, or wait for dmMaze to look at my crooked crafts

vanderalex commented 3 weeks ago

I have already fixed it by myself, It's just for future fixes in ocr_google_lens.py fixed function:

    def _apply_no_uppercase(self, text: str) -> str:
        def capitalize_first_letter(text):
            # Capitalize the first letter of each sentence
            sentences = re.split(r'(?<=[.!?…])\s+', text.strip())
            return ' '.join(sentence.capitalize() for sentence in sentences)
        lower_text = text.lower()
        return capitalize_first_letter(lower_text)