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", "")) )) { MetaphAdd("K"); current +=2; break; } //special case 'caesar' if((current == 0) AND StringAt(current, 6, "CAESAR", "")) { MetaphAdd("S"); current +=2; break; } if(StringAt(current, 4, "CHIA", "")) { //italian 'chianti' MetaphAdd("K"); current +=2; break; } if(StringAt(current, 2, "CH", "")) { //find 'michael' if((current > 0) AND StringAt(current, 4, "CHAE", "")) { MetaphAdd("K", "X"); current +=2; break; } 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", "")) { MetaphAdd("K"); current +=2; break; } //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", " ", ""))) { MetaphAdd("K"); } else { if(current > 0) { if(StringAt(0, 2, "MC", "")) //e.g., "McHugh" MetaphAdd("K"); else MetaphAdd("X", "K"); } else MetaphAdd("X"); } 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", "")) { MetaphAdd("X"); current += 3; break; } //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", "")) MetaphAdd("KS"); else //'bacci', 'bertucci', other italian MetaphAdd("X"); current += 3; break; } else {//Pierce's rule MetaphAdd("K"); current += 2; break; } if(StringAt(current, 2, "CK", "CG", "CQ", "")) { MetaphAdd("K"); current += 2; break; } if(StringAt(current, 2, "CI", "CE", "CY", "")) { //italian vs. english if(StringAt(current, 3, "CIO", "CIE", "CIA", "")) MetaphAdd("S", "X"); else MetaphAdd("S"); current += 2; break; } //else MetaphAdd("K"); //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;