# The Double Metaphone Search Algorithm

June 2000/The Double Metaphone Search Algorithm/Figure 1

#### Figure 1: The part of the Double Metaphone algorithm that processes the letter 'C'

```case 'C':
if((current > 1  )//various germanic
AND !IsVowel(current - 2)
AND StringAt((current - 1), 3, "ACH", "")
AND ((GetAt(current + 2) != 'I')
AND ((GetAt(current + 2) != 'E')
OR StringAt((current - 2), 6, "BACHER", "MACHER", "")) )) {
}
//special case 'caesar'
if((current == 0) AND StringAt(current, 6, "CAESAR", "")) {
}
if(StringAt(current, 4, "CHIA", "")) {  //italian 'chianti'
}
if(StringAt(current, 2, "CH", "")) {
//find 'michael'
if((current > 0) AND StringAt(current, 4, "CHAE", "")) {
}
if((current == 0)  //greek roots e.g. 'chemistry', 'chorus'
AND (StringAt((current + 1), 5, "HARAC", "HARIS", "")
OR StringAt((current + 1), 3, "HOR",
"HYM", "HIA", "HEM", ""))
AND !StringAt(0, 5, "CHORE", "")) {

}
//germanic, greek, or otherwise 'ch' for 'kh' sound
if((StringAt(0, 4, "VAN ", "VON ", "")
OR StringAt(0, 3, "SCH", ""))

// 'architect but not 'arch', 'orchestra', 'orchid'
OR StringAt((current - 2), 6, "ORCHES", "ARCHIT",
"ORCHID")
OR StringAt((current + 2), 1, "T", "S", "")
OR ((StringAt((current - 1), 1, "A", "O", "U", "E", "")
OR (current == 0))

//e.g., 'wachtler', 'wechsler', but not 'tichner'
AND StringAt((current + 2), 1, "L", "R", "N", "M", "B",
"H", "F", "V", "W", " ", ""))) {
} else {
if(current > 0) {
if(StringAt(0, 2, "MC", ""))  //e.g., "McHugh"
}
}
current +=2; break;
}
//e.g, 'czerny'
if(StringAt(current, 2, "CZ", "")
AND !StringAt((current - 2), 4, "WICZ", "")) {
MetaphAdd("S", "X"); current += 2; break;
}
//e.g., 'focaccia'
if(StringAt((current + 1), 3, "CIA", "")) {
}
//double 'C', but not if e.g. 'McClellan'
if(StringAt(current, 2, "CC", "") AND !((current == 1)
AND (GetAt(0) == 'M')))
//'bellocchio' but not 'bacchus'
if(StringAt((current + 2), 1, "I", "E", "H")
AND !StringAt((current + 2), 2, "HU", "")) {

//'accident', 'accede' 'succeed'
if(((current == 1) AND (GetAt(current - 1) == 'A'))
OR StringAt((current - 1), 5, "UCCEE", "UCCES", ""))

else  //'bacci', 'bertucci', other italian

current += 3; break;
} else {//Pierce's rule
}
if(StringAt(current, 2, "CK", "CG", "CQ", "")) {
}
if(StringAt(current, 2, "CI", "CE", "CY", "")) {
//italian vs. english
if(StringAt(current, 3, "CIO", "CIE", "CIA", ""))
else
current += 2; break;
}  //else

//name sent in 'mac caffrey', 'mac gregor
if(StringAt((current + 1), 2, " C", " Q", " G", ""))
current += 3;
else
if(StringAt((current + 1), 1, "C", "K", "Q", "")
AND !StringAt((current + 1), 2, "CE", "CI", ""))

current += 2; else current += 1;
break;

```

### More Insights

 To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.