At 3:37 AM +0900 12/5/05, TomRossi7 wrote:
How would you recommend implementing something like a fuzzy search with
Ruby and a SQL database. For example, I want to search a field in a
table for anything that is similar to “Frank Smithe”. I would want an
array of matches with some sort of score telling me how good of a match
the item received (“frank smithe” 100%, “frank smith” 90%).
Soundex is a phonetic algorithm for indexing names by their sound when
pronounced in English. The basic aim is for names with the same
pronunciation to be encoded to the same string so that matching can
despite minor differences in spelling. Soundex is the most widely
all phonetic algorithms and is often used (incorrectly) as a synonym
If you process your database’s names into a column of Soundex encodings,
you should be able to search this for an encoded target word. You could
then post-process the results to get the “score” for each one. Note
you may want to look around for alternative encodings (eg, Metaphone).