Levenshtein Distance Calculator
Advanced text analysis tool to calculate edit distance, visualize the dynamic programming matrix, and generate step-by-step edit paths for strings.
About
The Levenshtein Distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other. It is named after the Soviet mathematician Vladimir Levenshtein, who considered this distance in 1965.
This metric is critical in fields ranging from computer science to biology. In software, it powers spell checkers, optical character recognition (OCR) correction systems, and fuzzy search logic. In bioinformatics, similar algorithms (like Needleman-Wunsch) are used to align DNA and protein sequences to identify evolutionary relationships or mutations.
Formulas
The Levenshtein distance between two strings a (of length i) and b (of length j) is given by levij:
Where 1(ai ≠ bj) is the indicator function equal to 0 when the characters are the same and 1 otherwise.
Reference Data
| Metric | Description | Operations | Use Case |
|---|---|---|---|
| Levenshtein | Standard edit distance. | Insert, Delete, Substitute | Spell checking, NLP, DNA alignment. |
| Damerau-Levenshtein | Extension of Levenshtein. | Ins, Del, Sub, Transposition | Typo correction (swapped adjacent keys). |
| Hamming | Only for strings of equal length. | Substitution only | Error correcting codes, telecommunications. |
| Jaro-Winkler | Similarity score (0-1). | Matching characters, transpositions | Record linkage, duplicate detection (names). |
| LCS | Longest Common Subsequence. | Insert, Delete | Diff utilities (Git), file comparison. |