Metaphone
From Wikipedia, the free encyclopedia
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
- Survey of Phonetic Matching
- Open Source Spell Checker
- Page for PHP implementation of Metaphone
- Project Dedupe
- Ruby implementation included in http://rubyforge.org/projects/text
- 'Sounds alike' word generator
[edit] Downloadable Implementations
- Soundex, Metaphone, and Double Metaphone implementation in Java
- Soundex, Metaphone, Caverphone implementation in Python
- Text::Metaphone Perl module from CPAN
- Text::DoubleMetaphone Perl module from CPAN
- OCaml implementation of Double Metaphone
- PHP implementation by Stephen Woodbridge
- Ruby implementation included in http://english.rubyforge.org
- Ruby implementation included in http://rubyforge.org/projects/text/
- 4GL implementation by Robert Minter
- CodeProject's article about double metaphone implementations
- FileMaker Pro custom function, requiring FileMaker Pro Advanced to implement
- Spanish Metaphone in PHP (downloads a PHP file as text), from a comment in the PHP Metaphone Manual Page