MetaphoneMatcher Function

Number of input and output field

Number of input field : Two
Number of output field : One

A measure of similarity between two strings. It returns a value in the interval [0.0, 1.0], where 0.0 indicates that the two strings are completely different and 1.0 indicates that they are identical.

This transformation function uses the Metaphone algorithm to measure the similarity between two strings. Metaphone is a phonetic algorithm that transforms words based on English pronunciation rules, producing a phonetic representation that can be compared for similarity.

The resulting Metaphone code consists of characters from the set {0, B, F, H, J, K, L, M, N, P, R, S, T, W, X, Y}. At the beginning of a word, vowels from the set {A, E, I, O, U} may also appear.

This approach is particularly useful for comparing words that sound similar but may be spelled differently.

Metaphone code computation algorithm

  1. Remove all repeating neighboring letters except letter C.
  2. The beginning of the word should be transformed using the following rules:
    KN → N
    GN → N
    PN → N
    AE → E
    WR → R
  3. Remove B letter at the end, if it is after M letter.
  4. Replace C using the rules below:
    With X: CIA → XIA, SCH → SKH, CH → XH
    With S: CI → SI, CE → SE, CY → SY
    With K: C → K
  5. Replace D using the following rules:
    With J: DGE → JGE, DGY → JGY, DGI → JGY
    With T: D → T
  6. Replace GH → H, except it is at the end or before a vowel.
  7. Replace GN → N and GNED → NED, if they are at the end.
  8. Replace G using the following rules
    With J: GI → JI, GE → JE, GY → JY
    With K: G → K
  9. Remove all H after a vowel but not before a vowel.
  10. Perform following transformations using the rules below:
    CK → K
    PH → F
    Q → K
    V → F
    Z → S
  11. Replace S with X:
    SH → XH
    SIO → XIO
    SIA → XIA
  12. Replace T using the following rules
    With X: TIA → XIA, TIO → XIO
    With 0: TH → 0
    Remove: TCH → CH
  13. Transform WH → W at the beginning. Remove W if there is no vowel after it.
  14. If X is at the beginning, then replace X → S, else replace X → KS
  15. Remove all Y which are not before a vowel.
  16. Remove all vowels except vowel at the start of the word.


The algorithm’s time complexity is O(n)