aeidon.agents.TextAgent¶
Source: aeidon/agents/text.py
Anchestors: aeidon.delegate.Delegate, builtins.object
- class aeidon.agents.TextAgent¶
Automatic correcting of texts.
Methods¶
- TextAgent.break_lines(indices, doc, patterns, length_func, max_length, max_lines, skip=False, max_skip_length=32768, max_skip_lines=32768, register=-1)¶
Break lines to fit defined maximum line length and count.
indices can be None to process all subtitles. patterns should be a sequence of instances of aeidon.Pattern. length_func should return the length of a string argument. max_length should be the maximum allowed length of lines in the same scale as returned by length_func. max_lines may be violated to avoid violating max_length. If skip is True, subtitles that do not violate or do not manage to reduce max_skip_length and max_skip_lines are skipped.
Raise re.error if a bad regular expression among patterns.
- TextAgent.capitalize(indices, doc, patterns, register=-1)¶
Capitalize texts as defined by patterns.
indices can be None to process all subtitles. patterns should be a sequence of instances of aeidon.Pattern. Raise re.error if a bad regular expression among patterns.
- TextAgent.correct_common_errors(indices, doc, patterns, register=-1)¶
Correct common human and OCR errors in texts.
indices can be None to process all subtitles. patterns should be a sequence of instances of aeidon.Pattern. Raise re.error if a bad regular expression among patterns.
- TextAgent.remove_hearing_impaired(indices, doc, patterns, register=-1)¶
Remove hearing impaired parts from subtitles.
indices can be None to process all subtitles. patterns should be a sequence of instances of aeidon.Pattern. Raise re.error if a bad regular expression among patterns.
- TextAgent.spell_check_join_words(indices, doc, language, register=-1)¶
Join misspelled words based on spell-checker suggestions.
Raise enchant.Error if dictionary instatiation fails.
- TextAgent.spell_check_split_words(indices, doc, language, register=-1)¶
Split misspelled words based on spell-checker suggestions.
Using this is usually not a good idea unless you have an insane dictionary that contains all possible compound words in language. Raise enchant.Error if dictionary instatiation fails.