Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version r0682

This example illustrates how the following Double Metaphone algorithm functions operate in 

D s product
rtrue
.

  • DOUBLEMETAPHONE - Computes a primary and secondary phonetic encoding for an input string. Encodings are returned as a two-element array. See DOUBLEMETAPHONE Function.
  • DOUBLEMETAPHONEQUALS - Compares two input strings using the Double Metaphone algorithm. Returns true if they phonetically match. See DOUBLEMETAPHONEEQUALS Function.

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:

D trans
RawWrangletrue
p03Value'dblmeta_s1'
Typestep
WrangleTextderive type: single value: DOUBLEMETAPHONE(string1) as: 'dblmeta_s1'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueDOUBLEMETAPHONE(string1)
p03NameNew column name
SearchTermNew formula

You can compare string1 and string2 using the DOUBLEMETAPHONEEQUALS function:

D trans
RawWrangletrue
p03Value'compare'
Typestep
WrangleTextderive type: single value: DOUBLEMETAPHONEEQUALS(string1, string2, 'normal') as: 'compare'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueDOUBLEMETAPHONEEQUALS(string1, string2, 'normal')
p03NameNew column name
SearchTermNew formula

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.