From a08ecce024f9b1f87921568bd1fdb7bf4fb488a1 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 5 Nov 2022 23:46:48 +0100 Subject: [PATCH] fix test --- tests/test_hypothesis.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_hypothesis.py b/tests/test_hypothesis.py index 948699ba..2ad636a5 100644 --- a/tests/test_hypothesis.py +++ b/tests/test_hypothesis.py @@ -174,7 +174,7 @@ def jaro_winkler_similarity(pattern, text, prefix_weight=0.1): return Sim -def partial_ratio_short_needle(s1, s2): +def partial_ratio_short_needle_impl(s1, s2): if not s1 and not s2: return 100 @@ -182,7 +182,7 @@ def partial_ratio_short_needle(s1, s2): return 0 if len(s1) > len(s2): - return partial_ratio_short_needle(s2, s1) + return partial_ratio_short_needle_impl(s2, s1) parts = [ s2[max(0, i) : min(len(s2), i + len(s1))] for i in range(-len(s1), len(s2)) ] @@ -192,6 +192,16 @@ def partial_ratio_short_needle(s1, s2): return res +def partial_ratio_short_needle(s1, s2): + if len(s1) != len(s2): + return partial_ratio_short_needle_impl(s1, s2) + else: + return max( + partial_ratio_short_needle_impl(s1, s2), + partial_ratio_short_needle_impl(s2, s1), + ) + + def cdist_scorer(queries, choices, scorer): matrix = np.zeros((len(queries), len(choices)), dtype=np.uint8)