world.EditDistance
Returns the Levenshtein Edit Distance between two words
Prototype
long EditDistance(BSTR Source, BSTR Target);
Description
Returns the "edit distance" between two words.
This is intended for use in the spell checker or similar applications, where you need to know how close one word is to another.
The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
For example, the Levenshtein distance between "kitten" and "sitting" is 3, since the following three edits change one into the other, and there is no way to do it with fewer than three edits:
1. kitten --> sitten (substitution of 's' for 'k')
2. sitten --> sittin (substitution of 'i' for 'e')
3. sittin --> sitting (insert 'g' at the end).
VBscript example
Note EditDistance ("food", "fod") ' --> 1
Note EditDistance ("food", "fodder") ' --> 3
Lua example
Note (EditDistance ("food", "fod")) --> 1
Note (EditDistance ("food", "fodder")) --> 3
Lua notes
Also available as utils.edit_distance.
Return value
The edit distance between the two numbers.
Related topic
See also
| Function | Description |
|---|---|
| Metaphone | Returns the metaphone code for the supplied word |