Skip to content

Levenshtein distance is a method for determining the minimum operation to correct the misspelled vocabulary or when you trying to convert a string to another.

Notifications You must be signed in to change notification settings

miladnouriezade/Levenshtein-Distance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

                                        Information Retrieval and Organisation
                                                    Dell Zhang

Edit Distance

The (minimum) edit distance between two strings s1 and s2 is the minimum number of basic operations to convert s1 to s2.

Levenshtein-Distance

􏰀 Levenshtein distance: the admissible basic operations are: insert, delete, and replace 􏰀 Levenshtein distance dog→do: 1 (deletion) 􏰀 Levenshtein distance cat→cart: 1 (insertion) 􏰀 Levenshtein distance cat→cut: 1 (replacement) 􏰀 Levenshtein distance cat→act: 2 (2 replacements or 1 insertion and 1 deletion)

Computing Distance

Image of Levenshtein's final Matrix Image Source!

Each cell will contain

 the (cheapest) cost of getting
 from the string on the left-hand side to the string on the right-hand side

􏰀We know the costs for

the uppermost row and the leftmost column:

􏰀 we have to get from “” to GEORDIE by inserting characters

􏰀 we have to get from GEORGE to “” by deleting characters

Image of Levenshtein's initial matrix

(C) (B)
(A) *

For other cells, take the minimum of costs

􏰀 Coming from (A): 􏰀 add 1 to cost in (A) — (insertion)

􏰀 Coming from (B): 􏰀 add 1 to cost in (B) — (deletion)

􏰀 Coming from (C): 􏰀 if characters in row and column are equal, copy cost from (c) 􏰀 otherwise, add 1 to cost in (C) — (replacement)

About

Levenshtein distance is a method for determining the minimum operation to correct the misspelled vocabulary or when you trying to convert a string to another.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages