spell:levenshtein-distance( $str1 as xs:string, $str2 as xs:string ) as xs:integer
Given two strings, returns the Levenshtein distance between those strings. The Levenshtein distance is a measure of how many operations it takes to transform a string into another string, and it is useful in determining if a word is spelled correctly, or in simply comparing how "different" two words are.
Parameters | |
---|---|
str1 | The first input string. |
str2 | The second input string. |
The spell:levenshtein-distance
function is a built-in
function and does not require the import module
statement
in the XQuery prolog.
The spell:levenshtein-distance
function throws an exception
if one of the strings is 256 or more characters in length and the other
is at least 1 character in length.
spell:levenshtein-distance("albatros","albetros") => 1
spell:levenshtein-distance("cat", "cats") => 1
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.