From: Rich Morin Date: 2005-12-05T03:58:53+09:00 Subject: Re: Fuzzy Searching a Database 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 occur despite minor differences in spelling. Soundex is the most widely known of all phonetic algorithms and is often used (incorrectly) as a synonym for "phonetic algorithm". -- http://en.wikipedia.org/wiki/Soundex 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 that you may want to look around for alternative encodings (eg, Metaphone). -r -- email: rdm@cfcl.com; phone: +1 650-873-7841 http://www.cfcl.com - Canta Forda Computer Laboratory http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc.