def levenshtein_distance(str1, str2):
    """
    Function to find the Levenshtein distance between two words/sentences;
    gotten from http://rosettacode.org/wiki/Levenshtein_distance#Python

    Args:
        str1 (str)
        str2 (str)

    Returns:
        int
    """
    if len(str1) > len(str2):
        str1, str2 = str2, str1
    distances = range(len(str1) + 1)
    for index2, char2 in enumerate(str2):
        new_distances = [index2 + 1]
        for index1, char1 in enumerate(str1):
            if char1 == char2:
                new_distances.append(distances[index1])
            else:
                new_distances.append(1 + min((distances[index1], distances[index1 + 1], new_distances[-1])))
        distances = new_distances
    return distances[-1]
dataset/ETHPy150Open chartbeat-labs/textacy/textacy/math_utils.py/levenshtein_distance/original