http://www.zorba-xquery.com/modules/data-cleaning/phonetic-string-similarity
Description
Before using any of the functions below please remember to import the module namespace:
import module namespace simp = "http://www.zorba-xquery.com/modules/data-cleaning/phonetic-string-similarity";
This library module provides phonetic string similarity functions, comparing strings with basis on how they sound. These metrics are particularly effective in matching names, since names are often spelled in different ways that sound the same. The logic contained in this module is not specific to any particular XQuery implementation.
Author
Bruno Martins
XQuery version and encoding
xquery version "1.0" encoding "utf-8";
Namespaces
| simp | http://www.zorba-xquery.com/modules/data-cleaning/phonetic-string-similarity |
| ver | http://www.zorba-xquery.com/options/versioning |
Function Summary
metaphone-key($s1 as xs:string) as xs:stringReturns the Metaphone key for a given string. | |
metaphone($s1 as xs:string, $s2 as xs:string) as xs:booleanChecks if two strings have the same Metaphone key. | |
soundex-key($s1 as xs:string) as xs:stringReturns the Soundex key for a given string. | |
soundex($s1 as xs:string, $s2 as xs:string) as xs:booleanChecks if two strings have the same Soundex key. |
Functions
metaphone-key#1
declare function simp:metaphone-key(
$s1 as xs:string
) as xs:string Returns the Metaphone key for a given string.
The Metaphone algorithm produces variable length keys as its output, as opposed to Soundex's fixed-length keys.
Example usage : metaphone-key("ALEKSANDER")
The function invocation in the example above returns : "ALKSNTR"
Parameters
$s1 as xs:stringThe string.
Returns
xs:stringThe Metaphone key for the given input string.
Examples
metaphone#2
declare function simp:metaphone(
$s1 as xs:string,
$s2 as xs:string
) as xs:boolean Checks if two strings have the same Metaphone key.
Example usage : metaphone("ALEKSANDER", "ALEXANDRE")
The function invocation in the example above returns : true
Parameters
$s1 as xs:stringThe first string.$s2 as xs:stringThe second string.
Returns
xs:booleanReturns true if both strings have the same Metaphone key and false otherwise.
Examples
soundex-key#1
declare function simp:soundex-key(
$s1 as xs:string
) as xs:string Returns the Soundex key for a given string.
Example usage : soundex-key("Robert")
The function invocation in the example above returns : "R163"
Parameters
$s1 as xs:stringThe string.
Returns
xs:stringThe Soundex key for the given input string.
Examples
soundex#2
declare function simp:soundex(
$s1 as xs:string,
$s2 as xs:string
) as xs:boolean Checks if two strings have the same Soundex key.
Example usage : soundex( "Robert" , "Rupert" )
The function invocation in the example above returns : true
Parameters
$s1 as xs:stringThe first string.$s2 as xs:stringThe second string.
Returns
xs:booleanReturns true if both strings have the same Soundex key and false otherwise.