all repos — videocr @ 3f73cb9bcafbd639ef5791a846b861d633cdb9dc

Extract hardcoded subtitles from videos using machine learning

adjust text similarity metrics
Yi Ge me@yige.ch
Sat, 27 Apr 2019 03:18:27 +0200
commit

3f73cb9bcafbd639ef5791a846b861d633cdb9dc

parent

a3986b32790cb33bc607f95749255b558052d982

1 files changed, 3 insertions(+), 3 deletions(-)

jump to
M videocr/models.pyvideocr/models.py

@@ -48,12 +48,12 @@ self.confidence = sum(word.confidence for word in self.words)

self.text = ' '.join(word.text for word in self.words) # remove chars that are obviously ocr errors - translate_table = {ord(c): None for c in '<>{};`@#$%^*_=\\'} + translate_table = {ord(c): None for c in '<>{}[];`@#$%^*_=~\\'} translate_table[ord('|')] = 'I' self.text = self.text.translate(translate_table).strip() def is_similar_to(self, other: PredictedFrame, threshold=70) -> bool: - return fuzz.partial_ratio(self.text, other.text) >= threshold + return fuzz.ratio(self.text, other.text) >= threshold class PredictedSubtitle:

@@ -81,7 +81,7 @@ if self.frames:

return self.frames[-1].index return 0 - def is_similar_to(self, other: PredictedSubtitle, threshold=70) -> bool: + def is_similar_to(self, other: PredictedSubtitle, threshold=90) -> bool: return fuzz.partial_ratio(self.text, other.text) >= threshold def __repr__(self):