/** * Handles 'W' cases */ private int handleW(String value, DoubleMetaphoneResult result, int index) { if (contains(value, index, 2, "WR")) { //-- can also be in middle of word --// result.append('R'); index += 2; } else { if (index == 0 && (isVowel(charAt(value, index + 1)) || contains(value, index, 2, "WH"))) { if (isVowel(charAt(value, index + 1))) { //-- Wasserman should match Vasserman --// result.append('A', 'F'); } else { //-- need Uomo to match Womo --// result.append('A'); } index++; } else if ((index == value.length() - 1 && isVowel(charAt(value, index - 1))) || contains(value, index - 1, 5, "EWSKI", "EWSKY", "OWSKI", "OWSKY") || contains(value, 0, 3, "SCH")) { //-- Arnow should match Arnoff --// result.appendAlternate('F'); index++; } else if (contains(value, index, 4, "WICZ", "WITZ")) { //-- Polish e.g. "filipowicz" --// result.append("TS", "FX"); index += 4; } else { index++; } } return(index); }
/** * Handles 'R' cases */ private int handleR(String value, DoubleMetaphoneResult result, int index, bool slavoGermanic) { if (index == value.length() - 1 && !slavoGermanic && contains(value, index - 2, 2, "IE") && !contains(value, index - 4, 2, "ME", "MA")) { result.appendAlternate('R'); } else { result.append('R'); } return(charAt(value, index + 1) == 'R' ? index + 2 : index + 1); }
/** * Handles 'S' cases */ private int handleS(String value, DoubleMetaphoneResult result, int index, bool slavoGermanic) { if (contains(value, index - 1, 3, "ISL", "YSL")) { //-- special cases "island", "isle", "carlisle", "carlysle" --// index++; } else if (index == 0 && contains(value, index, 5, "SUGAR")) { //-- special case "sugar-" --// result.append('X', 'S'); index++; } else if (contains(value, index, 2, "SH")) { if (contains(value, index + 1, 4, "HEIM", "HOEK", "HOLM", "HOLZ")) { //-- germanic --// result.append('S'); } else { result.append('X'); } index += 2; } else if (contains(value, index, 3, "SIO", "SIA") || contains(value, index, 4, "SIAN")) { //-- Italian and Armenian --// if (slavoGermanic) { result.append('S'); } else { result.append('S', 'X'); } index += 3; } else if ((index == 0 && contains(value, index + 1, 1, "M", "N", "L", "W")) || contains(value, index + 1, 1, "Z")) { //-- german & anglicisations, e.g. "smith" match "schmidt" // // "snider" match "schneider" --// //-- also, -sz- in slavic language altho in hungarian it // // is pronounced "s" --// result.append('S', 'X'); index = contains(value, index + 1, 1, "Z") ? index + 2 : index + 1; } else if (contains(value, index, 2, "SC")) { index = handleSC(value, result, index); } else { if (index == value.length() - 1 && contains(value, index - 2, 2, "AI", "OI")) { //-- french e.g. "resnais", "artois" --// result.appendAlternate('S'); } else { result.append('S'); } index = contains(value, index + 1, 1, "S", "Z") ? index + 2 : index + 1; } return(index); }