Page tree

Release 9.2


Contents:

   

Contents:


Compares two input strings using the Double Metaphone algorithm. An optional threshold parameter can be modified to adjust the tolerance for matching.

The Double Metaphone algorithm processes an input string render a primary and secondary spelling for it. For English language words, the algorithm removes silent letters, normalizes combinations of characters to a single definition, and removes vowels, except from the beginnings of words. In this manner, the algorithm can normalize inconsistencies between spellings for better matching. For more information, see https://en.wikipedia.org/wiki/Metaphone.

Tip: This function is useful for performing fuzzy matching between string values, such as between potential join key values.

Source values can be string literals, column references, or expressions that evaluate to strings.

Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.

Basic Usage

String literal reference example:

doublemetaphoneequals('My String', 'my string')

Output: Returns the value true.

Column reference example:

doublemetaphoneequals(string1, string2, 'weak')

Output: Returns the comparison of string1 and string2 column values using the Double Metaphone algorithm. The 'weak' parameter input means that only the secondary encodings for each input must match.

Syntax and Arguments

doublemetaphoneequals(string_ref1, string_ref2, match_threshold)


ArgumentRequired?Data TypeDescription
string_ref1YstringName of first column or string literal to apply to the function
string_ref2YstringName of second column or string literal to apply to the function
match_thresholdNstringOptional string value for the matching threshold to use in the comparison. Default value is Normal.

For more information on syntax standards, see Language Documentation Syntax Notes.

string_ref1, string_ref2

String literal, column reference, or expression whose elements you want to filter through the Double Metaphone algorithm.

Usage Notes:

Required?Data TypeExample Value
YesString literal, column reference, or expression evaluating to a stringmyString1

match_threshold

String literal identifying the threshold that determines a match according to the Double Metaphone encodings of the input strings. Accepted values:

Threshold ValueDescription
'strong'The primary encodings of the two input strings must match.
'normal'(Default) The primary encoding of one input string must match either of the encodings of the other input string.
'weak'Either primary or secondary encoding of one input string must match either encoding of the other input string.

Usage Notes:

Required?Data TypeExample Value
YesString literal

'strong'


Examples


Tip: For additional examples, see Common Tasks.

Example - Phonetic string comparisons

This example illustrates how to use double metaphone functions to generate phonetic spellings in  Designer Cloud Enterprise Edition.

Functions:

ItemDescription
DOUBLEMETAPHONE Function Returns a two-element array of primary and secondary phonetic encodings for an input string, based on the Double Metaphone algorithm.
DOUBLEMETAPHONEEQUALS Function Compares two input strings using the Double Metaphone algorithm. An optional threshold parameter can be modified to adjust the tolerance for matching.

Source:

The following table contains some example strings to be compared. 

string1string2notes
My Stringmy stringcomparison is case-insensitive
judgejugetypo
knocknocksilent letters
whitewitemissing letters
recordrecordtwo different words in English but match the same
pairpearthese match but are different words.
bookkeeperbook keeperspaces cause failures in comparison
test1test123digits are not compared
the end.the end….punctuation differences do not matter.
a elephantan elephanta and an are treated differently.


Transformation:

You can use the DOUBLEMETAPHONE function to generate phonetic spellings, as in the following:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula DOUBLEMETAPHONE(string1)
Parameter: New column name 'dblmeta_s1'

You can compare string1 and string2 using the DOUBLEMETAPHONEEQUALS function:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula DOUBLEMETAPHONEEQUALS(string1, string2, 'normal')
Parameter: New column name 'compare'

Results:

The following table contains some example strings to be compared. 

string1dblmeta_s1string2compareNotes
My String["MSTRNK","MSTRNK"]my stringTRUEcomparison is case-insensitive
judge["JJ","AJ"]jugeTRUEtypo
knock["NK","NK"]nockTRUEsilent letters
white["AT","AT"]witeTRUEmissing letters
record["RKRT","RKRT"]recordTRUEtwo different words in English but match the same
pair["PR","PR"]pearTRUEthese match but are different words.
bookkeeper["PKPR","PKPR"]book keeperFALSEspaces cause failures in comparison
test1["TST","TST"]test123TRUEdigits are not compared
the end.["0NT","TNT"]the end….TRUEpunctuation differences do not matter.
a elephant["ALFNT","ALFNT"]an elephantFALSE a and an are treated differently.

See Also for EXAMPLE - Double Metaphone Functions:

 

 

This page has no comments.