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 (i.e. insertions, deletions or substitutions) required to change one word into the other.
Based on the implementation of the algorithms proposed in the Wikipedia "http://en.wikipedia.org/wiki/Levenshtein_distance".
It uses CRL2DArray implementation: "https://github.com/tGilani/CRL2DArray". Thanks to tGilani.
- Drag the
CL2DArray
folder into your project. - Drag the
NSString+Levenshtein
folder into your project. - Include
NSString+Levenshtein.h
, where you want to use it.
NSString * s1 = @"L'Ampolla";
NSString * s2 = @"Ampolla";
NSString * s3 = @"L'Aldea";
NSLog(@"Lev 1=>2: %d, Lev 1=>3: %d", [s1 LevenshteinDistance: s2], [s1 LevenshteinDistance: s3]);