943,844 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 5891
  • MySQL RSS
Feb 10th, 2006
0

Compare 2 Lists of Words

Expand Post »
I'm looking for a way to compare 2 lists of keywords and return the number of matches.

I'm currently working with PHP and MySQL, but I'm not sure how to go about this task. Any suggestions are appreciated.

Thanks,

J_
Similar Threads
Reputation Points: 27
Solved Threads: 6
Posting Whiz in Training
J_Search is offline Offline
284 posts
since Aug 2005
Feb 10th, 2006
0

Re: Compare 2 Lists of Words

(additional info)

I have not entered the data yet. So I'm open to just about anything. Here's what I'm planning.

(this part I have)
html form: user enters url
php: visits url and extracts the keywords and description meta tag values.

(I don't have this)
mysql:[table: 2 columns: column1 & column2] column1- phrase or one word
colum2- list of keywords relative to column1

Essentially, the php will visit the site, extract the keywords and compare them to the database keywords (column2) counting the number of matches. The php will return the column1 value for the column2 value that returned the most matches.
Reputation Points: 27
Solved Threads: 6
Posting Whiz in Training
J_Search is offline Offline
284 posts
since Aug 2005
Mar 8th, 2006
0

Re: Compare 2 Lists of Words

For simply comparing 2 lists of words for matches, I'd leave the database out of it. You can store your results or the keywords in the database if you want, but for the actual comparison, check out PHP's array_diff() function.
http://www.php.net/manual/en/function.array-diff.php

PS: For the part where you retrieve the headers and meta tags of the pages server-side, I know you said you had this working, but my class_http would make that job quite easy. It's a robust screen-scraping class and even supports making WebDAV requests. It is very easy to use.
http://www.troywolf.com/articles/php/class_http/
Reputation Points: 36
Solved Threads: 6
Posting Whiz
Troy is offline Offline
354 posts
since Jun 2005
Mar 8th, 2006
0

Re: Compare 2 Lists of Words

Troy,

Thanks a lot for the response. I was wondering if anyone was going to respond.

Some things have changed since my last post. I have about 155+ categories (individual names) and each has a list of keywords.

I'll want to compare one list of keywords with each of the category’s lists. I've already designed the database structure (normalized, I think), so I'm not so worried about that any longer.

As for the tag extractor, I have a very simple solution:

[PHP]while (!feof ($fp))
{
$buf = trim(fgets($fp, 4096));
$cont .= $buf;
}

preg_match("/$start(.*)$end/s",$cont,$match);

echo 'Title<br>';
echo $match[1];
echo '<br><br>';

echo 'URL<br>';[/PHP]
Reputation Points: 27
Solved Threads: 6
Posting Whiz in Training
J_Search is offline Offline
284 posts
since Aug 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Multiple results
Next Thread in MySQL Forum Timeline: HELP! MySQL with phpMyAdmin 2.5.5-p\1





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC