Brian Dunning's FileMaker Custom Functions

LevenshteinDistance ( string1 ; string2 )

Returns the Levenshtein distance between two text strings

  Be the first to rate this function Log in to vote

Carson Lind   Carson Lind - Show more from this author
Eagle Optimizations, LLC
http://eagleopz.com

Share on Facebook Share on Twitter

  Sample input:
LevenshteinDistance ( "kitten" ; "sitting" )
  Sample output:
3

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

FileMaker 18+ required (uses the While function).

Calculates the Levenshtein distance between two text strings.
Info can be found here: https://en.wikipedia.org/wiki/Levenshtein_distance
This method uses the "Iterative with two matrix rows" approach, using FileMaker lists instead of rows.

Performance on this function is pretty good compared to the options that are out there.
Small text strings (like single words) process very quickly.
Larger text strings will take time. Initial tests show that comparing two 500 character text strings takes ~10sec

This function does use a local variable ($__t) which i cleans out at the end.
If you happen to be using a variable by that name in a script, and then call this function, it will clear the variable out.

Thanks to Russell Watson for the improvement on constructing the initial sequential number list using a JSON array of nulls.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: