Learn R Programming

phonics (version 1.0.0)

metaphone: Generate phonetic versions of strings with Metaphone

Description

The function metaphone phonentically encodes the given string using the metaphone algorithm.

Usage

metaphone(word, maxCodeLen = 10L)

Arguments

word

string or vector of strings to encode

maxCodeLen

maximum length of the resulting encodings, in characters

Value

a character vector containing the metaphones of word, or an NA if the word value is NA

Details

There is some discrepency with respect to how the metaphone algorithm actually works. For instance, there is a version in the Java Apache Commons library. There is a version provided within PHP. These do not provide the same results. On the questionable theory that the implementation in PHP is probably more well known, this code should match it in output.

This implementation is based on a Javascript implementation which is itself based on the PHP internal implementation.

The variable maxCodeLen is the limit on how long the returned metaphone should be.

See Also

Other phonics: caverphone, cologne, lein, mra_encode, nysiis, onca, phonex, rogerroot, soundex, statcan

Examples

Run this code
# NOT RUN {
metaphone("wheel")
metaphone(c("school", "benji"))

# }

Run the code above in your browser using DataLab