private string TryConcatenate(string word, string wordStart, string wordEnd, PhoneticTable phoneticTable) { if (word == wordStart + wordEnd) { return phoneticTable.GetPhoneticValueOf(wordStart) + " [dash] " + phoneticTable.GetPhoneticValueOf(wordEnd); } else { return null; } }
private string GetPhoneticValue(string word, PhoneticTable phoneticTable) { string phoneticValue = phoneticTable.GetPhoneticValueOf(word); if (phoneticValue == null) phoneticValue = GetPhoneticValueOfWordUsingSimilarWordEnding(word, phoneticTable); return phoneticValue; }
private string GetWordEndsWith(string englishEnding, PhoneticTable phoneticTable) { foreach (HomophoneGroup homophoneGroup in phoneticTable) { foreach (string currentWord in homophoneGroup) { if (currentWord.EndsWith(englishEnding)) { return phoneticTable.GetPhoneticValueOf(currentWord); } } } return null; }
private string GetPhoneticValueOfWordUsingSimilarWordEnding(string word, PhoneticTable phoneticTable) { string englishEnding; if (word.Length >= howManyEnglishLetterForEnding) englishEnding = word.Substring(word.Length - howManyEnglishLetterForEnding); else englishEnding = word; string similarWord = GetWordEndsWith(englishEnding, phoneticTable); if (similarWord == null) return null; return phoneticTable.GetPhoneticValueOf(similarWord); }