strings.levenshtein_distance¶
Attributes¶
Functions¶
|
Benchmark the Levenshtein distance function. |
|
Implementation of the Levenshtein distance in Python. |
Compute the Levenshtein distance between two words (strings). |
Module Contents¶
- strings.levenshtein_distance.benchmark_levenshtein_distance(func: collections.abc.Callable) None ¶
Benchmark the Levenshtein distance function. :param str: The name of the function being benchmarked. :param func: The function to be benchmarked.
- strings.levenshtein_distance.levenshtein_distance(first_word: str, second_word: str) int ¶
Implementation of the Levenshtein distance in Python. :param first_word: the first word to measure the difference. :param second_word: the second word to measure the difference. :return: the levenshtein distance between the two words. Examples: >>> levenshtein_distance(“planet”, “planetary”) 3 >>> levenshtein_distance(“”, “test”) 4 >>> levenshtein_distance(“book”, “back”) 2 >>> levenshtein_distance(“book”, “book”) 0 >>> levenshtein_distance(“test”, “”) 4 >>> levenshtein_distance(“”, “”) 0 >>> levenshtein_distance(“orchestration”, “container”) 10
- strings.levenshtein_distance.levenshtein_distance_optimized(first_word: str, second_word: str) int ¶
Compute the Levenshtein distance between two words (strings). The function is optimized for efficiency by modifying rows in place. :param first_word: the first word to measure the difference. :param second_word: the second word to measure the difference. :return: the Levenshtein distance between the two words. Examples: >>> levenshtein_distance_optimized(“planet”, “planetary”) 3 >>> levenshtein_distance_optimized(“”, “test”) 4 >>> levenshtein_distance_optimized(“book”, “back”) 2 >>> levenshtein_distance_optimized(“book”, “book”) 0 >>> levenshtein_distance_optimized(“test”, “”) 4 >>> levenshtein_distance_optimized(“”, “”) 0 >>> levenshtein_distance_optimized(“orchestration”, “container”) 10
- strings.levenshtein_distance.first_word¶