I have list of full names names and trying to compare/search matching phonetically similar full names; I am using Double metaphone
in my c#
say my list is like this;
Abdul Hameed Khan
Shadab Akbar
Nawab Zameer Ahmed Baloch
Richard Hyden
Abdullah Habib
Abu Saleh Muhammad
Ravi Kumar
Ameet Kumar Rathore
Amit Shah
when I try to search the in Double Metaphone
it is going to search for only initial word (name).
How would make this search if I write Hameed, this should return Abdul Hameed Khan. currently it is returning only with first name. One thing more, How Do I compare Arabic or Urdu names in this algo.
here outer code work;
Hashtable wordsMap = new Hashtable();
FileStream wordsFile = File.OpenRead("..\\..\\..\\names.txt");
StreamReader reader = new StreamReader(wordsFile);
String word = reader.ReadLine();
while (word != null)
{
DoubleMetaphone mp = new DoubleMetaphone(word);
//Associate word with primary key
ArrayList words = (ArrayList)wordsMap[mp.PrimaryKey];
if (words == null)
{
words = new ArrayList();
wordsMap[mp.PrimaryKey] = words;
}
words.Add(word);
//Associate with with alternate key also
if (mp.AlternateKey != null)
{
words = (ArrayList)wordsMap[mp.AlternateKey];
if (words == null)
{
words = new ArrayList();
wordsMap[mp.AlternateKey] = words;
}
words.Add(word);
}
//Read the next word
word = reader.ReadLine();
}
//Begin prompting for search words
while (true)
{
System.Console.Write("\nEnter search term (q to quit): ");
String searchWord = System.Console.ReadLine().Trim();
if (searchWord.Length == 0 || searchWord == "q")
{
break;
}
DoubleMetaphone searchMphone = new DoubleMetaphone(searchWord);
//Search for matches to the primary key
ArrayList matches = (ArrayList)wordsMap[searchMphone.PrimaryKey];
if (matches != null)
{
foreach (String matchingWord in matches)
{
System.Console.WriteLine("\tFound: {0}", matchingWord);
}
}
//Search for matches to the alt, if present
if (searchMphone.AlternateKey != null)
{
matches = (ArrayList)wordsMap[searchMphone.AlternateKey];
if (matches != null)
{
foreach (String matchingWord in matches)
{
System.Console.WriteLine("\tFound: {0}", matchingWord);
}
}
}
}
this source code as reference used: https://www.codeproject.com/Articles/4624/Implement-Phonetic-Sounds-like-Name-Searches-wit