# Finding Degree of match with Soundex or Metaphone

I am working on a search where user would search names. Spelling mistakes are bound to happen. I have used edit distance, soundex and metaphone implementations in java so far. Each one separately and then different combinations too. Finally, a combination of soundex and metaphone seemed to work. There are more than 30 thousand names that would be searched for the match when ever a user enters a name. The search is sequential and would stop when ever a match is found. Now the problem is. Lets say in fol figure:-

   User Input Name = "Peeter"

----------------------------------------------------
Serial       Name
----------------------------------------------------
1           Tom
2           Petay (Near match say 70%)
3           Jack
4           Peteh (Near Match say 75%)
5           Peter (The closest Match say 100%)
----------------------------------------------------


The closest match for "Peeter" is "Peter" and near match is "Petay", "Peteh" etc. The search would stop at "Petay", returning "Petay" as the name which would be least expected by the user. So for me, 2 solutions comes to mind.

1. Search all 30 thousand names every time, get a list of all matches and ask user to choose the best match
2. Secondly, present 3 or say 5 top matching (by top matching i mean the closest match, let say more than 90% similar sounding) names to user.

I already have implemented option 1 but it returns some times more than 100 matches! it would not be possible for the user to go through all of them. So is there any way to implement option 2 mentioned above? i.e to find out to what degree soundex or metaphone match is made to a name.

• I can't tell if you're asking about the algorithms you're using or whether there's a bug in your code that uses them. – David Richerby Oct 16 '14 at 23:18
• @DavidRicherby Sir i have tried to improve my point of view. Your guidance would be appreciated. – learner Oct 17 '14 at 10:17

You can use K-nearest with the data points you have like % ,freq, or score of the edit and soundex algo.

• Could you elaborate your answer? – Evil Jul 16 '18 at 0:40
• you have the implementation of different algorithms. So give them wieght in 0-1 scale then sort the values of words accordingly. Choose top 5 or top k – Shashi Tripathi Jul 17 '18 at 16:52
• Maybe a little more (say, why this sticks) and via edit, it would be awesome. Thank you. – Evil Jul 17 '18 at 18:13