@METAPHONE
— Returns a
roughly phonetic code for an English word.
Syntax:
%@METAPHONE[
word,
length,
flags]
word | the word or words to process |
length | the maximum length of the codes to return (8) |
flags | set to 1 for better compatibility |
Metaphone codes are meant to roughly approximate the pronunciation of a word. Words that sound similar should have similar Metaphone codes. You can use this function to compare the sounds of words, to suggest similar words, or to group words by pronunciation.
If you pass more than one word, separate them with spaces. The resulting codes will also be separated by spaces.
rem Compare two words:
set word1=cougher
set word2=coffer
if %@metaphone[%word1] == %@metaphone[%word2] echo "%word1" may sound like "%word2".
By default, this function returns Metaphone codes of up to eight characters
long. You can specify a different length with the length
parameter, e.g. %@metaphone[
word,10]
to return ten-letter Metaphone codes. Legal values are 4 to 20.
• Note: Values returned by this function are not guaranteed to match those generated by any other implementation. Documentation of the Metaphone algorithm is invariably unclear and self-contradictory, and never seems to agree with the corresponding code. This is my attempt to implement Lawrence Philips’s original algorithm to the best of my limited understanding, with a few additional tweaks thrown in.
More specifically, comparing against assertFull_v1.1.txt,
dated 2011-11-25, by the Metaphone-standards
project, @METAPHONE
produces different codes for 40 out of
2753 words: about 98.5% agreement. If flags is
set to 1, there are no mismatches — but I still cannot guarantee
perfect agreement with any other implementation.