Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Nov 5, 2022
1 parent 3d1ccd3 commit a08ecce
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/test_hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ 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

if not s1 or not 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))
]
Expand All @@ -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)

Expand Down

0 comments on commit a08ecce

Please sign in to comment.