PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 1st, 2012, 10:46 PM
omardealo omardealo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 omardealo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 35 sec
Reputation Power: 0
Talking Function Most repeated words

Hello ,

I am looking for a " function Most 10 repeated words " from field [ page_keywords ] in database table [ pages ] ...

the words in field like that
page,google,facebook,smile,more,post,thread,msn,elc.

i want count all words and select only Most 10 repeated words and explode "," and without number and any another signs like [@,#,$,%,^,&,*,elc]

to get in the end Most 10 repeated words like this

google facebook page page


thnx ,


Reply With Quote
  #2  
Old December 2nd, 2012, 12:28 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 29 m 55 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Quote:
Originally Posted by omardealo
the words in field like that
page,google,facebook,smile,more,post,thread,msn,elc.

Well that sucks. Can you change your database structure at all?

Reply With Quote
  #3  
Old December 2nd, 2012, 07:35 PM
omardealo omardealo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 omardealo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
Well that sucks. Can you change your database structure at all?


change for what and why ?
on any database ,the tags words in field like same ..
page,google,facebook,smile,more,post,thread,msn,elc.

Reply With Quote
  #4  
Old December 2nd, 2012, 08:14 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 29 m 55 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Change for why: it's bad data structure and is hard to use. As you're finding out.
Change for what: rather than store everything as a comma-separated list, store everything in a table with one row per page per keyword.
Code:
page id | keyword
--------+--------
      1 | page
      1 | google
      1 | facebook
      1 | smile
      1 | more
      1 | post
      1 | thread
      1 | msn

So the question stands: can you change the database structure?

Reply With Quote
  #5  
Old December 2nd, 2012, 08:45 PM
omardealo omardealo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 omardealo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
Change for why: it's bad data structure and is hard to use. As you're finding out.
Change for what: rather than store everything as a comma-separated list, store everything in a table with one row per page per keyword.
So the question stands: can you change the database structure?


okay , requinix
maybe u are right ... but i can't change for that actually
listen i use that Function for same database and same field


PHP Code:
function get_keys($text,$limit=10){
            
$separaotr " ";   // the separator between the words
            
$text str_replace(array('&','^',',',';','<','>','_','$','%','#','@','+','=','-','/','*',')','(','0',']','[','{','}'),$separaotr,$text) ;
            
$text trim(strtolower($text));
            
$text implode($separaotrarray_slice(explode($separaotr ,$text), 0$limit));
            
$tags array_unique(explode($separaotr,$text));
            
$num count($tags) ;   //  number of tags you want
            
for ($z=0;$z<=$num;$z++){
             
$words .= '<a title="'.$tags[$z].'" href="search.php?q='.$tags[$z].'">'.$tags[$z].'</a> ';
             if(
$z $num-1){
               
$words .= '  ';
             }
            }
            return 
$words;



this function show The words without repetition and without Signs , worked fine
but i want only Most 10 repeated words
can u Modify for what I want ...

the query :

PHP Code:
 $tags = @mysql_query("SELECT page_keywords FROM pages ") or die(mysql_error()); 


used function :

PHP Code:
echo get_keys($keywords,50); 



thnx , requinix

Reply With Quote
  #6  
Old December 2nd, 2012, 09:16 PM
NotionCommotion NotionCommotion is offline
Contributing User
Click here for more information.
 
Join Date: Sep 2006
Posts: 1,464 NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 6 h 21 m 36 sec
Reputation Power: 526
Why can't the database schema be changed as requinix suggested? Is some else responsible for the database? If so, they should be fired.

Reply With Quote
  #7  
Old December 2nd, 2012, 09:27 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 29 m 55 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
If you really can't do anything about it then the solution is (looks like) what you have: get all the keywords from all the pages and tally them in PHP.

Reply With Quote
  #8  
Old December 2nd, 2012, 10:21 PM
omardealo omardealo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 omardealo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
If you really can't do anything about it then the solution is (looks like) what you have: get all the keywords from all the pages and tally them in PHP.


i do that already , i get all keywords from all pages
by this
PHP Code:
 $tags = @mysql_query("SELECT page_keywords FROM pages ") or die(mysql_error()); 


and Query results come like that
PHP Code:
 page,google,facebook,smile,more,post,thread,msn,elc


so , where's the function Which will be it job
Get only Most 10 repeated words without number and any another signs

Last edited by requinix : December 2nd, 2012 at 10:52 PM.

Reply With Quote
  #9  
Old December 2nd, 2012, 10:53 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 29 m 55 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Don't yell. You won't win.

The function will be the one you write. Because we're not going to write it for you.
You already have a list of the keywords. If you need something to count the keywords then
PHP Code:
 $count = array();
// for each $keyword in the list {
    
if (isset($count[$keyword])) $count[$keyword] = 0;
    
$count[$keyword]++;
// } 

Reply With Quote
  #10  
Old December 2nd, 2012, 11:17 PM
omardealo omardealo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 omardealo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
Don't yell. You won't win.

The function will be the one you write. Because we're not going to write it for you.
You already have a list of the keywords. If you need something to count the keywords then
PHP Code:
 $count = array();
// for each $keyword in the list {
    
if (isset($count[$keyword])) $count[$keyword] = 0;
    
$count[$keyword]++;
// } 


okay .. i understand
I did not ask you to write new function
I thought that there already function Available for this job
and i don't yell , sorry but u want me modification the database and i don't want do this ...
thnx ... requinix


Administration can be closed subject

Reply With Quote
  #11  
Old December 2nd, 2012, 11:42 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 29 m 55 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Quote:
Originally Posted by omardealo
okay .. i understand
I did not ask you to write new function
I thought that there already function Available for this job

That counts keywords in your database? Not really. That's a very specific question.
Comments on this post
omardealo agrees: thnx

Reply With Quote
  #12  
Old December 3rd, 2012, 01:14 AM
omardealo omardealo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 omardealo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
That counts keywords in your database? Not really. That's a very specific question.


i don't understand ur comment
anyway i will search more about i want
thnx for u !

Reply With Quote
  #13  
Old December 3rd, 2012, 05:08 AM
shane002 shane002 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 3 shane002 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 22 m 40 sec
Reputation Power: 0
Function Most repeated words

I am looking for a functions that would get me the most repeated word in a sentence and order desc by number of times.
Comments on this post
ptr2void disagrees: Useless spammer

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Function Most repeated words

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap