Tool to calculate the Levenshtein distance between 2 words (character string) and search for related words in the dictionary or in a list.

Levenshtein Distance - dCode

Tag(s) : Data Processing

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!

A suggestion ? a feedback ? a bug ? an idea ? *Write to dCode*!

The **Levenshtein distance** is an algorithmic method allowing to quantify a distance between two words (more generally between 2 strings of characters). Two close words (that is to say that few things separate them spelling: they have several letters in common, in the same position) will then have a small distance, while two very different words will have a large distance. This distance is also called edit distance and is equal to the minimum number of characters to be deleted, inserted, or replaced to move from one string to another.

__Example:__ `TAKE` and `MAKE` are similar graphically (a kind of near-homograph) and have a **Levenshtein distance** of 1

__Example:__ `CLOSE` and `CLOTHES` are similar phonetically (homophone) but orthographically far apart, they have a **Levenshtein distance** of 3

The distance from **Levenshtein** is symmetrical, the distance value from `STRING1` to `STRING2` is equal to the distance value from `STRING2` to `STRING1`

**Levenshtein**'s algorithm evaluates the number of differences between the two character strings, the differences can be of 3 types: a substitution (replacement of one character by another), an insertion (addition of a new character) or a deletion (deletion of a character).

$$ \operatorname{Distance}(a,b) = \begin{cases} ||a|| & \text{ if } ||b|| = 0, \\ ||b|| & \text{ if } ||a|| = 0, \\ \operatorname{Distance}(a', b') & \text{ if } a[0] = b[0] \\ 1 + \min \begin{cases} \operatorname{Distance}(a', b) \\ \operatorname{Distance}(a, b') \\ \operatorname{Distance}(a', b') \\ \end{cases} & \text{ otherwise } \end{cases} $$

With $ ||a|| $ the size of the string, and $ a' $ the string $ a $ deprived of its first character (noted $ a[0] $)

The **Levenshtein distance** measures the similarity between two strings of characters.

__Example:__ `DCODE` is at a distance of `2` from `DECODER` (1- add `E` and 2- add `R`)

__Example:__ `DECODER` is at a distance of `2` from `DCODE` (1- remove `E` and 2- remove `R`)

Use the dCode tool by entering a word and a dictionary with which to compare the word.

All words with a similar spelling will be returned.

Calculating the distance between 2 strings of characters can make it possible to know their quantity of differences and thus also their amount of similarity. So the **Levenshtein** calculation algorithm can be used to determine typing errors or misspellings, words for which the proximity of the compared chains is strong.

dCode retains ownership of the online "Levenshtein Distance" source code. Except explicit open source licence (indicated CC / Creative Commons / free), the "Levenshtein Distance" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "Levenshtein Distance" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, copy-paste, or API access for "Levenshtein Distance" are not public, same for offline use on PC, tablet, iPhone or Android ! Remainder : dCode is free to use.

Please, check our dCode Discord community for help requests!

NB: for encrypted messages, test our automatic cipher identifier!

levenshtein,distance,measure,word,typo,close,proximity,phonetic

Source : https://www.dcode.fr/levenshtein-distance

© 2021 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback

▲
Thanks to your feedback and relevant comments, dCode has developed the best 'Levenshtein Distance' tool, so feel free to write! Thank you!