This XQuery Module contains functions for string computations.
Conventions
All functions in this module and errors are assigned to the http://basex.org/modules/strings namespace, which is statically bound to the strings prefix.
Functions
strings:levenshtein
| Signatures
|
strings:levenshtein($string1 as xs:string, $string2 as xs:string) as xs:double
|
| Summary
|
Computes the Damerau-Levenshtein Distance for two strings and returns a double value (0.0 - 1.0). The distance is computed as follows:
1.0 - distance / max(length of strings)
1.0 is returned if the strings are equal; 0.0 is returned if the strings are too different.
|
| Examples
|
strings:levenshtein("flower", "flower") returns 1
strings:levenshtein("flower", "floewr") returns 0.83
strings:levenshtein("flower", "rewolf") returns 0.16
|
strings:soundex
| Signatures
|
strings:soundex($string as xs:string) as xs:string
|
| Summary
|
Computes the Soundex value for the specified string. The algorithm can be used to find and index English words with similar pronouncation.
|
| Examples
|
strings:soundex("Michael") returns M240
strings:soundex("OBrien") = strings:soundex("O'Brien") returns true
|
strings:cologne-phonetic
| Signatures
|
strings:cologne-phonetic($string as xs:string) as xs:string
|
| Summary
|
Computes the Kölner Phonetik value for the specified string. The algorithm was published by Hans Joachim Postel in 1969. Similar to Soundex, it is used to find similarly pronounced words in the German language.
|
| Examples
|
strings:cologne-phonetic("Michael") returns 645
every $s in ("Mayr", "Maier", "Meier") satisfies strings:cologne-phonetic($s) = "67" returns true
|
Changelog
The Module was introduced with Version 8.3.