Skip to content

Commit a08ecce

Browse files
committed
fix test
1 parent 3d1ccd3 commit a08ecce

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/test_hypothesis.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ def jaro_winkler_similarity(pattern, text, prefix_weight=0.1):
174174
return Sim
175175

176176

177-
def partial_ratio_short_needle(s1, s2):
177+
def partial_ratio_short_needle_impl(s1, s2):
178178
if not s1 and not s2:
179179
return 100
180180

181181
if not s1 or not s2:
182182
return 0
183183

184184
if len(s1) > len(s2):
185-
return partial_ratio_short_needle(s2, s1)
185+
return partial_ratio_short_needle_impl(s2, s1)
186186
parts = [
187187
s2[max(0, i) : min(len(s2), i + len(s1))] for i in range(-len(s1), len(s2))
188188
]
@@ -192,6 +192,16 @@ def partial_ratio_short_needle(s1, s2):
192192
return res
193193

194194

195+
def partial_ratio_short_needle(s1, s2):
196+
if len(s1) != len(s2):
197+
return partial_ratio_short_needle_impl(s1, s2)
198+
else:
199+
return max(
200+
partial_ratio_short_needle_impl(s1, s2),
201+
partial_ratio_short_needle_impl(s2, s1),
202+
)
203+
204+
195205
def cdist_scorer(queries, choices, scorer):
196206
matrix = np.zeros((len(queries), len(choices)), dtype=np.uint8)
197207

0 commit comments

Comments
 (0)