levenshteinSimilarity
Normalized Levenshtein similarity between two strings, in [0, 1] — 1 means identical,
0 means completely dissimilar relative to the longer string’s length. A convenience wrapper
around levenshteinDistance for scoring/ranking use cases.
Available since v3.1.1
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
a | string | The first string |
b | string | The second string |
caseSensitive | boolean | Whether the comparison is case-sensitive. Defaults to `true`. |
Returns
Section titled “Returns”number — A similarity score between 0 and 1; 1 when both strings are empty
Examples
Section titled “Examples”Score how close two strings are
Section titled “Score how close two strings are”A normalized [0, 1] score, handy for fuzzy-matching/ranking.
Identical strings score 1
Section titled “Identical strings score 1”Useful as a fuzzy-matching threshold cutoff.
