Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _str_sim(a, b, fn=textdistance.jaro_winkler):
"""
Wrapper function for the string similarity function
:param a: a string to compare
:param b: another string to compare
:param fn: the string similarity function from the textdistance package
:return: the similarity ratio
"""
return fn.normalized_similarity(a.lower(), b.lower())
def jaro_winkler_dist(s1: str, s2: str, scaling=0.1):
# jaro_dist = jaro_distance(s1, s2)
# # find prefix
# prefix = 0
# for i in range(min(len(s1), len(s2))):
# if s1[i] == s2[i]:
# prefix += 1
# else:
# break
# final_result = jaro_dist + prefix * scaling * (1-jaro_dist)
return textdistance.jaro_winkler.similarity(s1, s2)