Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthormihai
    • CommentTimeFeb 1st 2006
     permalink
    anyone has any idea if i can find a script that can show me how much two words are alike.
    example: cssBeauty <-> csdBaeuty ,and the result sould be in %

    p.s. it's not too hard to be done, i could make it, but hey why not use one ready made.
    Mike
  1.  permalink
    You would need a dictionary or library to compare words with.

    Unless you want to assign the alphabet depth (percentage) and calculate a percentage based on what letters are what (ie. a -> b, 1 letter off, 3.85% wrong, 96.15% accurate) and how many are wrong.

    Of course, you wouldn't know "how many are wrong" or "how far off" without a dictionary.

    Aspell and PHPspell are good ones.
    • CommentAuthormihai
    • CommentTimeFeb 2nd 2006
     permalink
    Here is exactly what i need this for, i have a database with names, and visitors must be able to search through the names in order to find out more details about the person. Can i use the database as a dictionary ? Something like spell-check as you mentioned, but it's with names. 10x for the links.
    •  
      CommentAuthornifkin
    • CommentTimeFeb 2nd 2006
     permalink
    Are they seperated into first and last name fields in the database?

    You could use something like metaphone() to search for similar phonetic matches, but the longer the text string you feed into it the less likely things are to match up.
    • CommentAuthormihai
    • CommentTimeFeb 2nd 2006
     permalink
    quite a interesting function, i'll have to make some test to see if it provides acceptable results when it comes to names.
  2.  permalink
    Why not just use a MySQL query with wild cards and MATCH and AGAINST

    $query = mysql_query("SELECT *, MATCH (`firstName`, `lastName`) AGAINST ('%" . $_GET['search'] . "%') AS `rating` FROM `namesList` WHERE MATCH (`firstName`, `lastName`) AGAINST ('%" . $_GET['search'] . "%') ORDER BY `rating` DESC");

    Or something like that. My example was a bit excessive but you get the idea.
Add your comments
    Username Password
  • Format comments as (Help)