note 33922 added to function.soundex
| From: | mail at gettheeawayspam dot iaindooley dot com | Date: | Fri, 11 Jul 2003 04:04:06 +0000 |
| Subject: | note 33922 added to function.soundex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51880@lists.php.net to get a copy of this message | ||
The soundex 'different letter in front' problem can be solved by using levenshtein() on
the soundex codes. in my application, which is searching a database of album names for entries that
match a particular user provided string, i do the following:
1. Search the database for the exact name
2. Search the database for entries where the name occurs anyway as a string
3. Search the database for entries where any of the words in the name (if the user has typed in more
than one word) is present, except for little words (and, the, of etc)
4. Then, if all this fails, I go to plan b:
- calculate the levenshtein distance (levenshtein()) between the user search term and each of the
entries in the database as a percentage of the length of the user search term entered
- calculate the levenshtein distance between the metphone codes of the user search term entered and
each field in the database as a percentage of the length of the metaphone code of the user search
term entered
- calculate the levenshtein distance between the soundex codes of the user search term entered and
each field in the database as a percentage of the length of the soundex code of the original user
search term entered
if any of these percentages is less than 50 (means that two soundex codes with different first
letters will be accepted!!) then the entry is accepted as a possible match.
----
Manual Page -- http://www.php.net/manual/en/function.soundex.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33922
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33922&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33922&report=yes