The function metaphone phonetically encodes the
given string using the metaphone algorithm.
metaphone(word, maxCodeLen = 10L, clean = TRUE)a character vector containing the metaphones of word,
or an NA if the word value is NA
string or vector of strings to encode
maximum length of the resulting encodings, in characters
if TRUE, return NA for unknown alphabetical characters
Metaphone has accumulated incompatible implementation variants. This function follows the traditional rules from Philips' 1990 algorithm; it is therefore not expected to reproduce PHP or Apache Commons Codec for every input.
The variable maxCodeLen is the limit on how long the returned
metaphone should be.
The metaphone algorithm is only defined for inputs over the
standard English alphabet, i.e., "A-Z.". Non-alphabetical
characters are removed from the string in a locale-dependent fashion.
This strips spaces, hyphens, and numbers. Other letters, such as
"Ü," may be permissible in the current locale but are unknown to
metaphone. For inputs outside of its known range, the output
is undefined and NA is returned and a warning this
thrown. If clean is FALSE, metaphone attempts
to process the strings. The default is TRUE.
James P. Howard, II, "Phonetic Spelling Algorithm Implementations for R," Journal of Statistical Software, vol. 95, no. 8, (2020), p. 1--21, <10.18637/jss.v095.i08>.
Lawrence Philips, "Hanging on the Metaphone," Computer Language, vol. 7, no. 12 (1990), p. 38--44.
Other phonics:
caverphone(),
cologne(),
lein(),
mra_encode(),
nysiis(),
onca(),
phonex(),
phonics(),
rogerroot(),
soundex(),
statcan()
metaphone("wheel")
metaphone(c("school", "benji"))
Run the code above in your browser using DataLab