1
1
from pathlib import Path
2
2
from typing import List
3
3
4
- from thefuzz import fuzz
4
+ from rapidfuzz import fuzz
5
5
6
6
7
7
def _match_percentage (str1 : str , str2 : str , score_cutoff : float = 0 ) -> float :
8
8
"""
9
- A wrapper around `thefuzz .fuzz.partial_ratio` to handle UTF-8 encoded
9
+ A wrapper around `rapidfuzz .fuzz.partial_ratio` to handle UTF-8 encoded
10
10
emojis that usually cause errors
11
11
12
12
`str` `str1` : a random sentence
@@ -19,12 +19,7 @@ def _match_percentage(str1: str, str2: str, score_cutoff: float = 0) -> float:
19
19
20
20
# ! this will throw an error if either string contains a UTF-8 encoded emoji
21
21
try :
22
- partial_ratio = fuzz .partial_ratio (str1 , str2 )
23
-
24
- if partial_ratio < score_cutoff :
25
- return 0
26
-
27
- return partial_ratio
22
+ return fuzz .partial_ratio (str1 , str2 , score_cutoff = score_cutoff )
28
23
29
24
# ! we build new strings that contain only alphanumerical characters and spaces
30
25
# ! and return the partial_ratio of that
@@ -41,12 +36,7 @@ def _match_percentage(str1: str, str2: str, score_cutoff: float = 0) -> float:
41
36
if each_letter .isalnum () or each_letter .isspace ()
42
37
)
43
38
44
- partial_ratio = fuzz .partial_ratio (new_str1 , new_str2 )
45
-
46
- if partial_ratio < score_cutoff :
47
- return 0
48
-
49
- return partial_ratio
39
+ return fuzz .partial_ratio (new_str1 , new_str2 , score_cutoff = score_cutoff )
50
40
51
41
52
42
def _parse_duration (duration : str ) -> float :
0 commit comments