TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Suggestions to a users question (http://www.talkphp.com/advanced-php-programming/2796-suggestions-users-question.html)

codingwizard 05-12-2008 02:03 PM

Suggestions to a users question
 
Hi all!

I'm looking to find out the best way to give a list of suggested answers to a user when they enter a question. For example like Kayako does when a user enters text for a new support ticket.

Is there some magical way of matching accurately or is it just a case of going through each word in the users text word by word and matching articles, seeing which match the most, sorting in ascending order and then displaying them?

Any help or guidance is appreciated.

ETbyrne 05-12-2008 03:25 PM

You could have a list and as the user types in it looks at the list for any matches like if you type in can't then you get a list like can't log in, can't do this, can't do that.

codingwizard 05-14-2008 04:33 PM

Yes, but the user is going to be entering a paragraph of text for their question and then it needs to display matching articles from the KB using an Ajax search. Surely searching for articles with every word wouldn't be accurate - how do we rate how much an article matches the question entered - like a relevance score with more matches = higher relevance?

drewbee 05-14-2008 07:33 PM

Here is how I would do it.

Step 1) Strip out common, unidentifable words to the article IE: and, but, I, we, are etc etc.
Step 2) out of each article, build an index of total words and how many times it appeared in the article.
Step 3) do the same for the new article being listed (build index of words & count)
Step 4) Find all keywords in new article which have a count greater then 3, then query against all of our previously submited articles of which contain all of the previously said keywords.
Step 5) Sort relevance by the articles which matched the most keywords from article new to article old

I personally would never do this with ajax though... way to resource intensive. I would only run this type of algorithim only when a new article is added, and cache the results in the database, in a new table containing a 1 > many relationship (article > related articles).


All times are GMT. The time now is 11:45 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0