difference() [v3]

Author: toralf Last Modified: 20100621


Calculates the difference between two strings. Works faster than Levenshtein distance.

Difference(string1, string2, maxOffset=5)

For the functions's parameters and return value, please see it's source code or the document.

Remarks

The original algorithm can be found here: http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html

See also Damerau–Levenshtein distance library: GUID=683cc900-9ec7-126a-9f10-15a625f9f073

The script does not have any official version number. I *Tuncay* have put one, because it is the third version he posted. And it does not have any documentation, so I made a simple one.

For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/post-364091.html#364091

License

nonexistent

Example

; #Include difference.ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

MsgBox % Difference( "A H K", "A H Kn" )       ;0.083333
MsgBox % Difference( "A H K", "A H K" )        ;0.000000
MsgBox % Difference( "A H K", "A h K" )        ;0.040000
MsgBox % Difference( "AHK", "" )               ;1.000000
MsgBox % Difference( "He", "Ben" )             ;0.500000
MsgBox % Difference( "Toralf", "ToRalf" )      ;0.033333
MsgBox % Difference( "Toralf", "esromneb" )    ;0.750000
MsgBox % Difference( "Toralf", "RalfLaDuce" )  ;0.420000