Re: Determining the similarity between a user supplied short piece of text (between 5 and 15 characters) and a list of similar length text items.
| From: | Daniel P. Brown | Date: | Thu, 15 Jul 2010 16:09:13 +0000 |
| Subject: | Re: Determining the similarity between a user supplied short piece of text (between 5 and 15 characters) and a list of similar length text items. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306924@lists.php.net to get a copy of this message | ||
On Thu, Jul 15, 2010 at 11:54, Richard Quadling <rquadling@gmail.com> wrote:
>
> I'm looking for is a way to compare what they've entered against a
> known list and to provide my 10 best guesses.
Look into the following functions and families:
levenshtein()
similar_text()
You wouldn't want to use metaphone() or soundex(), because you're
working with alphanumeric combinations, but if you want to be a
glutton for punishment, it could be fun. Something along the lines of
using levenshtein() to get the best matches, then similar_text() to
score each of the matches would probably be a viable solution for you.
The last time I incorporated something like that was for my own use
to track down a record in a MySQL database for which I could remember
just a small blip of text. It looked through about 23 million records
in under two minutes and I found exactly what it was for which I was
searching --- even though I was off by one word. Would've taken me
forever to find it using alternative methods.
--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/