DoubleMetaphone: 'Double Metaphone' phonetic algorithm

Description Usage Arguments Details Value Acknowledgement Note References See Also Examples

View source: R/DoubleMetaphone.R

Description

DoubleMetaphone converts strings to double metaphone phonetic codes.

Usage

1

Arguments

str

A character vector whose strings are to be encoded by double metaphone algorithm.

Details

An implementation of the Double Metaphone phonetic algorithm in R. If non-ASCII characters encountered in the input character vector str, a warning is issued and they are transliterated so that the accented characters are converted to their ASCII unaccented versions.

Value

Returns a list with two character vectors of the same length as the input vector. The first character vector contains the primary double metaphone encodings, while the second character vector contains the alternate encodings.

Acknowledgement

The C code for the double metaphone algorithm was adapted from Maurice Aubrey's perl module hosted at the gitpan/Text-DoubleMetaphone public github library along with the corresponding license information.

Note

In case of non-ASCII characters in strings, a warning is issued and accented characters are converted to their ASCII unaccented versions.

References

Philips, Lawrence. 2000. "The Double Metaphone Search Algorithm." C/C++ Users Journal 18 (6): 38-43. https://dl.acm.org/doi/10.5555/349124.349132.

See Also

phonetic, phonetics

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Return the primary and secondary Double Metaphone encodings for a character vector.
str1 <- c("Jyothi", "Jyoti")
str2 <- c("POLLACHI", "BOLLACHI")
DoubleMetaphone(str1)
DoubleMetaphone(str2)
## Not run: 
# Issue a warning in case of non-ASCII characters.
str3 <- c("J\xf5geva", "Jogeva")
DoubleMetaphone(str3) 
## End(Not run)

Example output

sh: 1: cannot create /dev/null: Permission denied
sh: 1: wc: Permission denied
Could not detect number of cores, defaulting to 1.
$primary
[1] "J0" "JT"

$alternate
[1] "AT" "AT"

$primary
[1] "PLX" "PLX"

$alternate
[1] "PLK" "PLK"

$primary
[1] "N"   "JJF"

$alternate
[1] "N"   "AKF"

Warning message:
In DoubleMetaphone(str3) : Non-ASCII characters were encountered.

PGRdup documentation built on Feb. 17, 2021, 5:06 p.m.