Krystian Cybulski
Krystian Cybulski

Reputation: 11118

Help me find the algorithm name - quantify difference between two words

I know there is an algorithm for seeing how "close" two words are together. The idea is that this algorithm adds 1 point to the score for every single letter addition or subtraction that is necessary to transform one word into the other. The lower this score, the "closer" the two words are together.

For example, if we take the word "word" and "sword", their distance is 1. To go from "word" to "sword" all you have to do as add an "s" in the beginning.

For "week" and "welk" the distance is 2. You need to subtract the "e" and add an "l".

I remember this algorithm is used for sorting the suggestion list in spell-checkers. I cannot recall the name of this algo.

What is this algorithm called?

Upvotes: 5

Views: 1791

Answers (5)

ChaosPandion
ChaosPandion

Reputation: 78292

Levenshtein Distance

Is it just me or is this simple algorithm great?

Upvotes: 11

Luke Schafer
Luke Schafer

Reputation: 9265

Levenshtein distance

http://en.wikipedia.org/wiki/Levenshtein_distance

Upvotes: 4

Chris Simmons
Chris Simmons

Reputation: 7266

Do you mean Levenshtein distance?

Upvotes: 3

Alex Martelli
Alex Martelli

Reputation: 882761

Levenshtein distance.

Upvotes: 4

stuartd
stuartd

Reputation: 73303

This sounds a lot like the Levenshtein distance algorithm

Upvotes: 4

Related Questions