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.

Thanks in advance.

  • $\begingroup$ 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. $\endgroup$ Oct 16, 2014 at 23:18
  • $\begingroup$ @DavidRicherby Sir i have tried to improve my point of view. Your guidance would be appreciated. $\endgroup$
    – learner
    Oct 17, 2014 at 10:17

1 Answer 1


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

  • 4
    $\begingroup$ Could you elaborate your answer? $\endgroup$
    – Evil
    Jul 16, 2018 at 0:40
  • $\begingroup$ 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 $\endgroup$ Jul 17, 2018 at 16:52
  • 2
    $\begingroup$ Maybe a little more (say, why this sticks) and via edit, it would be awesome. Thank you. $\endgroup$
    – Evil
    Jul 17, 2018 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.