SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Mars
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Google's <Do you mean>

    Hi

    What's the idea behind suggesting a correct keyword if a non-exist keyword was queried.

    For example, if I have this data in a database:
    Test
    Best
    Win
    etc..


    Suppose the user entered "Tist", My program should display do you mean "Test". Also, if "Wen" is entered, "win" should be display as an autosuggestion.

  2. #2
    SitePoint Addict bkennedy's Avatar
    Join Date
    Aug 2004
    Location
    michigan
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, you'd need a complete dictionary.
    if you have that, you can check it for the entered word. if it's not there, levenstein() might get you close, but it'll take a long time to do a test like that, i think

    well, look at levenstein(). it'll help a lot. you won't need a dictionary if you're only testing against words in your db.
    ----------------
    bob.kennedy
    ----------------

  3. #3
    Spacebug Beansprout's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    464
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    levenshtein()

    But yup...it'll take a while. You could hard-code those common mistakes
    Thermal Degree - web design with standards! (View our portfolio)
    Vidahost - shared and reseller linux hosting with real support
    Use my free file uploader!
    5.99 .com/net/org/biz/us/name domains; 2.99 .info!

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Mars
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    levenshtein() is all what I need!

    but am I going to store all of my field records in an array ?!
    Thanks guys

  5. #5
    SitePoint Addict bkennedy's Avatar
    Join Date
    Aug 2004
    Location
    michigan
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, i think you'd have to. you'd do a query for the fields that contain the keywords, and put them in an array. it's another DB hit, but i think it's all you can do, unless you hard code all the words in.
    you could have a cron job run a script that generates a php file that is an array declaration containing all of the keywords. it would run every day or hour or so, then include that file 'array declaration file' from your script.
    however, i don't know if it's faster to include a file, or to query the database.
    ----------------
    bob.kennedy
    ----------------


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •