示例#1
0
    def test_correct_common_errors(self):
        self.project.subtitles[0].main_text = "''Test''"
        self.project.subtitles[1].main_text = "123o456o789"
        manager = aeidon.PatternManager("common-error")
        self.project.correct_common_errors(self.project.get_all_indices(),
                                           aeidon.documents.MAIN,
                                           manager.get_patterns("Latn"))

        assert self.project.subtitles[0].main_text == '"Test"'
        assert self.project.subtitles[1].main_text == "12304560789"
示例#2
0
    def test_capitalize(self):
        for subtitle in self.project.subtitles:
            subtitle.main_text = "test. test i."
        manager = aeidon.PatternManager("capitalization")
        self.project.capitalize(self.project.get_all_indices(),
                                aeidon.documents.MAIN,
                                manager.get_patterns("Latn", "en"))

        for subtitle in self.project.subtitles:
            assert subtitle.main_text == "Test. Test I."
示例#3
0
 def _init_attributes(self):
     """Initialize values of page attributes."""
     self._manager = aeidon.PatternManager("line-break")
     self.conf = gaupol.conf.line_break
     self.description = _("Break text into lines of defined length")
     self.handle = "line-break"
     # TRANSLATORS: Keep these page titles short, since they
     # affect the width of the text correction assistant sidebar.
     self.page_title = _("Line-Break Patterns")
     self.page_type = Gtk.AssistantPageType.CONTENT
     self.title = _("Break lines")
示例#4
0
 def _init_attributes(self):
     """Initialize values of page attributes."""
     self._manager = aeidon.PatternManager("hearing-impaired")
     self.conf = gaupol.conf.hearing_impaired
     self.description = _("Remove explanatory texts meant for the hearing impaired")
     self.handle = "hearing-impaired"
     # TRANSLATORS: Keep these page titles short, since they
     # affect the width of the text correction assistant sidebar.
     self.page_title = _("Hearing Impaired Patterns")
     self.page_type = Gtk.AssistantPageType.CONTENT
     self.title = _("Remove hearing impaired texts")
示例#5
0
 def _init_attributes(self):
     """Initialize values of page attributes."""
     self._manager = aeidon.PatternManager("common-error")
     self.conf = gaupol.conf.common_error
     self.description = _("Correct common errors made by humans or image recognition software")
     self.handle = "common-error"
     # TRANSLATORS: Keep these page titles short, since they
     # affect the width of the text correction assistant sidebar.
     self.page_title = _("Common Error Patterns")
     self.page_type = Gtk.AssistantPageType.CONTENT
     self.title = _("Correct common errors")
示例#6
0
 def _init_attributes(self):
     """Initialize values of page attributes."""
     self._manager = aeidon.PatternManager("capitalization")
     self.conf = gaupol.conf.capitalization
     self.description = _("Capitalize texts written in lower case")
     self.handle = "capitalization"
     # TRANSLATORS: Keep these page titles short, since they
     # affect the width of the text correction assistant sidebar.
     self.page_title = _("Capitalization Patterns")
     self.page_type = Gtk.AssistantPageType.CONTENT
     self.title = _("Capitalize texts")
示例#7
0
    def test_remove_hearing_impaired(self):
        orig_length = len(self.project.subtitles)
        self.project.subtitles[0].main_text = "[Boo] Test."
        self.project.subtitles[1].main_text = "[Boo]"
        manager = aeidon.PatternManager("hearing-impaired")
        patterns = manager.get_patterns("Latn")
        for pattern in patterns:
            pattern.enabled = True
        self.project.remove_hearing_impaired(self.project.get_all_indices(),
                                             aeidon.documents.MAIN, patterns)

        assert self.project.subtitles[0].main_text == "Test."
        assert len(self.project.subtitles) == orig_length - 1
示例#8
0
    def test_break_lines(self):
        manager = aeidon.PatternManager("line-break")
        for subtitle in self.project.subtitles:
            subtitle.main_text = subtitle.main_text.replace(" ", "\n")
        self.project.break_lines(indices=None,
                                 doc=aeidon.documents.MAIN,
                                 patterns=manager.get_patterns("Latn"),
                                 length_func=len,
                                 max_length=44,
                                 max_lines=2)

        for subtitle in self.project.subtitles:
            assert subtitle.main_text.count("\n") <= 2
示例#9
0
 def test_get_patterns__policy_replace(self):
     self.manager = aeidon.PatternManager("line-break")
     assert self.manager.get_patterns("Latn", "en")
示例#10
0
 def setup_method(self, method):
     self.manager = aeidon.PatternManager("common-error")