[UPHPU] Smart spelling searches

Jonathan Gale jon at jtoo.net
Wed Sep 15 12:59:43 MDT 2004

John Anderson wrote:

> These might help -- but how will the SQL look? It seems like these can only work with data 
> once PHP has it. I need to be able to query the database using something like these..

Yes, I see your point.  The problem is you don't know the string to 
compare against until you actually receive it from the user (via a 
search form or something).  It would be _very_ inefficient to calculate 
the levenshtein distance between the search string and _every_ name in 
the database for each query!

With soundex it was easy because I just stored the SOUNDEX of a name 
along with the name in the database.

I wonder if the double metaphone [1] algorithm might work better for 
you.  According to this page [2] it works *better* with non-English 
words than soundex and metaphone.

[1] http://swoodbridge.com/DoubleMetaPhone/
[2] http://datamining.anu.edu.au/software/febrl/febrldoc/node20.html


More information about the UPHPU mailing list