Take me over?
NAME
Text::Metaphone - A modern soundex. Phonetic (english) encoding of words.
SYNOPSIS
use Text::Metaphone;
$metaWord = Metaphone($word); # phonetically encode $word.
# look at the max length of an encoding.
$metaMax = Text::Metaphone::MaxPhonemeLen;
# set the max encoding length.
Text::Metaphone::MaxPhonemeLen(10);
use Text::Metaphone qw(soundex);
$metaWord = soundex($word); # Same as Metaphone.
DESCRIPTION
Metaphone()
is a function whereby a string/word is broken down into a rough approximation of its english phonetic pronunciation. Very similar in concept and purpose to soundex (see Text::Soundex), but more comprehensive in its approach.
If you are using Text::Soundex in an existing program and wish to switch over to Metaphone, simply invoke this module as use Text::Metaphone qw(soundex);
rather than using Text::Soundex and soundex()
will become exactly the same as Metamorphosize()
. You might want to set Metaphone's maximum encoding length to 4, if your code expects a fixed size encoding (Text::Metaphone::MaxPhonemeLen(4);
).
If this doesn't excite you, then its YA module to give worms to ex-girlfriends. :)
FUNCTIONS
- Metaphone(STRING)
-
Takes any string and encodes it according to the Metaphone algorithm. Non-letters are ignored by the algorithm.
'sh' is encoded as 'X'. 'th' is encoded as '0' (I'll allow this to be set by the user, eventually.)
- soundex(STRING)
-
Simply an alias to
Metaphone()
. Activate it by importing this function. (use Text::Metaphone qw(soundex);
) - Text::Metaphone::MaxPhonemeLen([LENGTH])
-
Set or get the metaphone encoding limit. If called without any args, the current setting is returned. If given a positive integer, it uses that as the maximum length of a metaphone encoding which
Metaphone()
will produce. Anything else, and no limit is placed onMetaphone()
Normally, Metaphone limits its encoding to 6 characters by default. (I'm thinking of changing the default to unlimited.)
KNOWN BUGS
I guess this would be a pre-alpha, so I'm quite sure its infested. For gods sake, don't use it in production code.
The metaphone encoding is sure to change many times in the coming days/weeks/months before it stablizes, so don't be surprised if the encoding you get in this version is different from future versions.
Some words just don't encode right. "sugar" for instance, encodes to "SKR" (should be "XKR"). "Schwartz" encodes to "SKRTS" (should be "XRTS"). My name encodes improperly ("SKRN" instead of "XRN") This is a fault of the algorithm itself and can be improved to a point, but due to the massive inconsistancies in english, there's no way it will be perfect.
TO DO
- Allow the special sound encodings ('sh' and 'th') to be user defined.
- Improve the efficiency of the code. I'm shooting to outpace Text::Soundex.
- Add in functionality for automatically storing the metaencodings of common words.
- Port _Metamorphosize over to C/XS.
- I probably should think of a better than than "MaxPhonemeLen" :)
AUTHOR
Michael G Schwern, schwern@rt1.net, CPAN ID - MSCHWERN
Drop me a line you use this module (or want to use it, but won't because its untested... ESPECIALLY let me know if that's the case), find bugs, want a new dipthong added, etc...
SEE ALSO
Manual Pages
Books, Journals and Magazines
Binstock, Andrew & Rex, John. "Metaphone: A Modern Soundex." I<Practical Algorithms For Programmers.> Reading, Mass: Addion-Wesley, 1995 pp160-169
Contains an explaination 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." I<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.
Philips, Lawrence. I<Computer Language>, Vol. 7, No. 12 (December), 1990.
And here's the original Metaphone algorithm as presented in Pick BASIC.
COPYRIGHT AND LEGAL BULLSHIT
Copyright (c) 1995 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.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 450:
You forgot a '=back' before '=head1'
- Around line 472:
You forgot a '=back' before '=head1'