http://zorba.io/modules/data-cleaning/phonetic-string-similarity

View as XML or JSON.

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.

Function Summary

metaphone-key ($s1 as xs:string) as xs:string

Returns the Metaphone key for a given string.

metaphone ($s1 as xs:string, $s2 as xs:string) as xs:boolean

Checks if two strings have the same Metaphone key.

soundex-key ($s1 as xs:string) as xs:string

Returns the Soundex key for a given string.

soundex ($s1 as xs:string, $s2 as xs:string) as xs:boolean

Checks 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:string
The string.

Returns

xs:string
The Metaphone key for the given input string.

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:string
The first string.
s2 as xs:string
The second string.

Returns

xs:boolean
Returns true if both strings have the same Metaphone key and false otherwise.

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:string
The string.

Returns

xs:string
The Soundex key for the given input string.

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:string
The first string.
s2 as xs:string
The second string.

Returns

xs:boolean
Returns true if both strings have the same Soundex key and false otherwise.