How to use the textdistance.jaro_winkler function in textdistance

To help you get started, we’ve selected a few textdistance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jasonrig / address-net / addressnet / predict.py View on Github external
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())
github AlexYangLi / NLI_Keras / utils / features.py View on Github external
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)