Skip to content

Commit 1f7a01f

Browse files
committed
Avoid substring matches by using fuzz.ratio
1 parent 0952be1 commit 1f7a01f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CLI/videocr/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, index: int, pred_data: list[list], conf_threshold: float, zon
7575
self.text = '\n'.join(' '.join(word.text for word in line) for line in self.lines)
7676

7777
def is_similar_to(self, other: PredictedFrames, threshold=70) -> bool:
78-
return fuzz.partial_ratio(self.text, other.text) >= threshold
78+
return fuzz.ratio(self.text, other.text) >= threshold
7979

8080

8181
class PredictedSubtitle:
@@ -112,7 +112,7 @@ def index_end(self) -> int:
112112
return 0
113113

114114
def is_similar_to(self, other: PredictedSubtitle) -> bool:
115-
return fuzz.partial_ratio(self.text.replace(' ', ''), other.text.replace(' ', '')) >= self.sim_threshold
115+
return fuzz.ratio(self.text.replace(' ', ''), other.text.replace(' ', '')) >= self.sim_threshold
116116

117117
def __repr__(self):
118118
return f'{self.index_start} - {self.index_end}. {self.text}'

0 commit comments

Comments
 (0)