Metaphone

From Wikipedia, the free encyclopedia

Jump to: navigation, search

Metaphone is a phonetic algorithm, an algorithm for indexing words by their sound, when pronounced in English. The algorithm produces variable length keys as its output, as opposed to Soundex's fixed-length keys. Similar sounding words share the same keys.

Metaphone was developed by Lawrence Philips as a response to deficiencies in the Soundex algorithm. It is more accurate than Soundex[citation needed] because it uses a larger set of rules for English pronunciation. Metaphone is available as a built-in operator in a number of systems, including later versions of PHP.

The original author later produced a new version of the algorithm, which he named Double Metaphone, that produces more accurate results than the original algorithm.

Contents

[edit] Algorithm

From Ruby's Text library:

     [ /([bcdfhjklmnpqrstvwxyz])\1+/,
                        '\1' ],  # Remove doubled consonants except g.
                                 # [PHP] remove c from regexp.
     [ /^ae/,            'E' ],
     [ /^[gkp]n/,        'N' ],
     [ /^wr/,            'R' ],
     [ /^x/,             'S' ],
     [ /^wh/,            'W' ],
     [ /mb$/,            'M' ],  # [PHP] remove $ from regexp.
     [ /(?!^)sch/,      'SK' ],
     [ /th/,             '0' ],
     [ /t?ch|sh/,        'X' ],
     [ /c(?=ia)/,        'X' ],
     [ /[st](?=i[ao])/,  'X' ],
     [ /s?c(?=[iey])/,   'S' ],
     [ /[cq]/,           'K' ],
     [ /dg(?=[iey])/,    'J' ],
     [ /d/,              'T' ],
     [ /g(?=h[^aeiou])/,   ],
     [ /gn(ed)?/,        'N' ],
     [ /([^g]|^)g(?=[iey])/,
                       '\1J' ],
     [ /g+/,             'K' ],
     [ /ph/,             'F' ],
     [ /([aeiou])h(?=\b|[^aeiou])/,
                        '\1' ],
     [ /[wy](?![aeiou])/,  ],
     [ /z/,              'S' ],
     [ /v/,              'F' ],
     [ /(?!^)[aeiou]+/,    ],

[edit] See also

[edit] External links

[edit] Downloadable Implementations


Personal tools