| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jan 2009
Posts: 1
|
Hi, Could any one help me with this please.. I don't have much time left. I'm trying to calculate the 8-10 most frequent words in a text file and save them on MySQL database. could any one direct me how to do that. so far I've got this code which calculate the frequency for each word and print them out on text file but I need to remove the stop words and save the top 10 on my database. function word_frequency($text,$filename,$counter) { $FileName = $counter.'.txt'; $encodeText = file_get_contents ($FileName); $wordfrequenc = ""; $str = $encodeText; $word_count = (array_count_values(str_word_count(strtolower($str ),1))); ksort($word_count); foreach ($word_count as $key=>$val) { $wordfrequenc = $wordfrequenc." ".$key ." = ". $val."<br/>"; } //end foreach $myFile = $counter.'frequency.txt'; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $wordfrequenc); } //end function ?> Any suggestions? Many thanks.. |
|
|
|
![]() |
|