I have a regex/soundex type method:
public static string SoundEx(string word)
{
if (word.All(char.IsDigit))
{
//sentenceParts = words;
return word;
}
word = word.ToUpper();
word = word[0] +
Regex.Replace(
Regex.Replace(
Regex.Replace(
Regex.Replace(
Regex.Replace(
Regex.Replace(
Regex.Replace(word.Substring(1), "[AEIOUYHW]", ""), "[BFPV]+", "1"), "[CGJKQSXZ]+", "2"), "[DT]+", "3"), "[L]+", "4"), "[MN]+", "5"), "[R]+", "6");
return word;//word.PadRight(4, '0').Substring(0, 4);
}
This works fine on strings with one word but as soon as you dump a sentence in it can start acting funny.
"The big brown cat." and "The big brown dog."
Come up as a match. Now I understand it keeps the first char of the first word and then starts using the regex to match numbers to the vowels, etc. But how can I implement this on an entire sentence making it more accurate?