public static bool StringMatchesPhonetics(string s, IEnumerable<string> phoenitics) { DoubleMetaphone m = new DoubleMetaphone(); IEnumerable<string> lhsPhoenetics = m.Get(s); IEnumerable<string> rhsPhoenetics = phoenitics; foreach (string lhsPhoenetic in lhsPhoenetics) { foreach (string rhsPhoenetic in rhsPhoenetics) { if (rhsPhoenetic.Contains(lhsPhoenetic) && rhsPhoenetic.Length - lhsPhoenetic.Length <= 2) { return true; } } } return false; }
public static bool StringMatchesString(string lhs, string rhs) { DoubleMetaphone m = new DoubleMetaphone(); return StringMatchesPhonetics(lhs, m.Get(rhs)); }
public static string[] GetPhonetics(string s) { DoubleMetaphone m = new DoubleMetaphone(); return m.Get(s); }