stubarny Posted September 2, 2012 Share Posted September 2, 2012 Hello, Please could someone tell me how to apply synoyms to a search? For example a job search for "airline pilot" should also return jobs adverts for "first officer", "second officer" and "captain". I guess such a system would need prepopulating with millions of relationships, is there somewhere I can get such a file? Thanks, Stu Quote Link to comment https://forums.phpfreaks.com/topic/267920-returning-synonyms-for-a-search/ Share on other sites More sharing options...
Christian F. Posted September 3, 2012 Share Posted September 3, 2012 A good question this, if a bit too open-ended and missing on the details. However, for the purposes of this post I shall assume that we're speaking about a simple job listing, and that the list of synonyms is fairly limited. The very first thing you'll need, is a table listing all of the job descriptions and positions. Don't need more than an ID and a name for this. Next item on the list is a table for the relationships between the different descriptions, which needs to be a many-to-many relationship. After all, airline pilots are not the only ones who have "first officers", let alone "captain". Then I'll assume further that you have a table with a foreign key relation to the job_description table, which you want to search through. (Let's call it "employees".) Now, in this case I'd run a query against the employees table that looks something like this: SELECT * FROM `employees` WHERE `job_id` = $JobID OR `job_id` IN( SELECT `synonym_id` FROM `job_desc_syn` WHERE `job_id` = $JobID UNION SELECT `job_id` FROM `job_desc_syn` WHERE `synonym_id` = $JobID) Haven't tested it, and not knowing the details of your existing system, I can't really vouch for it being a good solution or not. It is, perhaps, the simplest one though. In any case, it should give you some ideas to work with, so that you can develop your own solution. A search on the net could very well offer you some more information, which would be highly recommended to read. When it comes to where you find a list of such words: I don't know, I'd try a search for it as well. As noted above, you've really given far too little information for us to be of any help on this point. PS: I recommend that you read this article. Quote Link to comment https://forums.phpfreaks.com/topic/267920-returning-synonyms-for-a-search/#findComment-1374795 Share on other sites More sharing options...
QuickOldCar Posted September 3, 2012 Share Posted September 3, 2012 You would need to use a dictionary that has synonyms or make such relationships. Can use wordnet http://wordnet.princeton.edu/ There are some online api's you can access, need to look around for one that suits your needs. Quote Link to comment https://forums.phpfreaks.com/topic/267920-returning-synonyms-for-a-search/#findComment-1374868 Share on other sites More sharing options...
QuickOldCar Posted September 3, 2012 Share Posted September 3, 2012 Here is an api http://words.bighugelabs.com/api.php Quote Link to comment https://forums.phpfreaks.com/topic/267920-returning-synonyms-for-a-search/#findComment-1374870 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.