| Module | Text::Levenshtein |
| In: |
lib/text/levenshtein.rb
|
Calculate the Levenshtein distance between two strings +str1+ and +str2+.
In Ruby 1.8, +str1+ and +str2+ should be ASCII, UTF-8, or a one-byte-per character encoding such as ISO-8859-*. They will be treated as UTF-8 if $KCODE is set appropriately (i.e. ‘u’). Otherwise, the comparison will be performed byte-by-byte. There is no specific support for Shift-JIS or EUC strings.
In Ruby 1.9+, the strings will be processed as UTF-8.
When using Unicode text, be aware that this algorithm does not perform normalisation. If there is a possibility of different normalised forms being used, normalisation should be performed beforehand.