Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/267920-returning-synonyms-for-a-search/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.