Distance
Distance class#
Contains functions for calculating the levenshtein distance between strings.
distance(string1: str, string2: str) -> Optional[int]
#
Returns the levenshtein distance between two strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string1 |
str
|
The first string to compare. |
required |
string2 |
str
|
The second string to compare. |
required |
Returns:
Type | Description |
---|---|
Optional[int]
|
The levenshtein distance between the two strings. |
Examples:
Source code in stringmatch/distance.py
distance_list(string: str, string_list: List[str]) -> List[Optional[int]]
#
Returns the levenshtein distance for a string and a list of strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
The string to compare. |
required |
string_list |
List[str]
|
The List of strings to compare to. |
required |
Returns:
Type | Description |
---|---|
List[Optional[int]]
|
The levenshtein distances between the two strings. |
Examples: