Common string similarity algorithms sim: (Σ* × Σ*) → [0, 1].
Open value range algorithms (like Hamming) are normalized.
Complexity: O(n)
def hamming_distance(str1: str, str2: str) -> intdef hamming(str1: str, str2: str) -> floatThe shorter string is padded with blank symbols to apply the algorithm.
Complexity: O(n²)
def levenshtein_distance(str1: str, str2: str) -> intdef levenshtein(str1: str, str2: str) -> floatComplexity: O(n²)
def damerau_levenshtein_distance(str1: str, str2: str) -> intdef damerau_levenshtein(str1: str, str2: str) -> floatComplexity: O(n²)
def jaro(str1: str, str2: str) -> floatComplexity: O(n²)
def jaro_winkler(str1: str, str2: str, p: float = 0.1) -> floatComplexity: O(n)
def jaccard(str1: str, str2: str) -> floatThe set based similarity algorithms use character and index combination to mimic set element identity (
{ (character, index) ∀ c ∈ S₁, S₂ }).
Complexity: O(n)
def sorensen_dice(str1: str, str2: str) -> floatComplexity: O(n)
def szymkiewicz_simpson(str1: str, str2: str) -> floatSzymkiewicz-Simpson is also simply known as “overlap”.