Jump to content
xisto Community
Sign in to follow this  
ruben1405241511

MySQLl Similarity.. like/regexp..

Recommended Posts

Hi folks,

I'm trying to realise a dictionary search, that means that I have got a row of words and I want to give out those that are similar to the search query.
For example if someone searches for "slup" it should give out words like this page:
http://forums.xisto.com/no_longer_exists/
but also terms like sluptastic, deslupnitration, slup brothers, the slup experience, sup, slu..
I'm a beginner concerning RegExp and well the "Like" request seems not to fulfill all my requirements.
I know that in PHP, I could use the levenshtein function, but that is not available in MySQL is it?
So many dictionaries use this kind of search, so there has to be some common way, could someone tell me which please?

Thanks a lot,
Ruben

PS.: I thought of a very "rough" regexp request + sorting the words after similarity (as said by levenshtein function) and only giving out the 50 best ones or something.

Share this post


Link to post
Share on other sites

That would make quite complex regex wouldn't it? I mean you'd have to have every kind of "similarity" in the regex or am I completely missing something? I think these features are done using functions that calculate a value for word similarity. I'm not a MySQL guru but I don't there exists functions for word similarity. I'm just going with hasard here... Maybe you could do a system that matches quite loosely with SQL LIKE. For example you could require there that all of the different characters in the search string would appear in the database values and that they would have to be in the same order. So with regex just allow any number of characters between the search characters. Or something more efficient. After the loose LIKE you could run the results through a better word matching algorithm and only display the words or phrases that you consider close enough.

Share this post


Link to post
Share on other sites

Thanks hercco,I sort of came to this conclusion to after googling a lot. But I'm not skilled with Reg.Exp at all, so I could make good use of a ready-to-use Reg.Exp (I can read them and transform them for my needs, but it takes me weeks to write one, that does what I want).I guess, it's not easy to just come up with one, but I thought, mayybe one of you knows a good page on the web, where you can find ready ones? I saw some, but they all kind of sucked with about 30 different Reg.Exps, none fitting my purpose.So if anyone here knows something helpful, pleaaaase post.

Share this post


Link to post
Share on other sites

I never learnt regular expressions myself, only the basic stuff which I usually don't need and always when I need to regexp, I first try to find something on the php.net site, but usually I just connect to irc.freenode.com and go to the #php where a lot of experienced people help you, really a good support channel for php developers, you also can discuss a lot. In fact I find freenode network really useful, even going to #mysql, #apache, #css, #xml, #c++ and more, you can get support and save your time, of course you need to obey the rules, usually stupid questions are ignored, so don't get bothered or don't be irritating :D it only annoys most of the people.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.