Metaphone(3pm)

πŸ“¦
this version Β· 6 versions
, in ubuntu stonking

πŸ’– Text::Metaphone πŸ’–

okay bestie, so this is the manual page for Text::Metaphone β€” it's giving a modern soundex, and it does phonetic encoding of words. that's the whole vibe. let's get into it πŸŽ€


✨ NAME ✨

Text::Metaphone β€” a modern soundex. phonetic encoding of words. it's literally the glow-up of soundex, no cap πŸ‘‘


🌸 SYNOPSIS 🌸

use Text::Metaphone;

# XWRN
my $phoned_word = Metaphone('Schwern');

so yes, 'Schwern' comes out the other side as XWRN and honestly? iconic. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so Metaphone() is this function where a string/word gets broken down into a rough approximation of its english phonetic pronunciation. think of it as soundex's cooler older sister β€” very similar in concept and purpose to soundex, but much more comprehensive in its approach. it ate, fr fr. ✨


πŸ’œ FUNCTIONS πŸ’œ

Metaphone

$phoned_word = Metaphone($word, $max_phone_len);

takes a word and encodes it according to the Metaphone algorithm. and this is important bestie: the algorithm only deals with alphabetical characters β€” everything else?? ignored. straight up not invited to the party. πŸ™ˆ

if $max_phone_len is provided, Metaphone will only encode up to that many characters for each word. so you can keep it short and cute if u want. πŸŽ€

also fun facts: 'sh' gets encoded as 'X', and 'th' gets encoded as '0'. and if u wanna change that?? it can be changed in the metaphone.h header file. iykyk. πŸ‘‘


πŸ’€ CAVEATS πŸ’€

Metaphone algorithm changes

okay so this part matters, listen up. πŸ“’

i (the module, bestie) have made a few minor changes to the traditional metaphone algorithm found in the books. the most significant one is that it will differenciate between SCH and SCHW β€” making the former K (as in School) and the latter sh (as in Schwartz and Schwern). very main character behavior honestly. 🌈

my changes can be turned off by defining the USE_TRADITIONAL_METAPHONE flag in metaphone.h.

🚨 okay this is the serious one 🚨 β€” due to these changes, any users of Metaphone v1.00 or earlier which have stored metaphonetic encodings, they should recalculate those with the new version. like. go redo them. don't just leave the old ones sitting there. 😭

🫢 AUTHOR 🫢

Michael G Schwern <schwern@pobox.com>


πŸ”₯ SEE ALSO πŸ”₯

Man pages

  • Text::Soundex β€” a simpler word hashing algorithm
  • Text::DoubleMetaphone β€” improved metaphone
  • Text::Phonetic β€” a collection of phonetic algorithms

Books, Journals and Magazines

  • Binstock, Andrew & Rex, John. "Metaphone: A Modern Soundex." Practical Algorithms For Programmers. Reading, Mass: Addion-Wesley, 1995 pp160-169

contains an explanation of the basic metaphone concept & algorithm and C code from which i learned of Metaphone and ported this module. πŸ’–

  • Parker, Gary. "A Better Phonetic Search." C Gazette, Vol. 5, No. 4 (June/July), 1990.

this is the public-domain C version of metaphone from which Binstock & Rex based their own.. i haven't actually read it. πŸ™ˆ (real)

  • Philips, Lawrence. Computer Language, Vol. 7, No. 12 (December), 1990.

and here's the original Metaphone algorithm as presented in Pick BASIC. πŸŽ€


Copyright (c) 1997, 1999, 2007-2008 Michael G Schwern. All Rights Reserved.

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay πŸ’…


and that's the whole page bestie!! mwah 🫢 this was perl v5.42.3, dated 2026-08-19 β€” go forth and phonetically encode responsibly, ily βœ¨πŸŒˆπŸ’–

πŸ“¦ where this page comes from