Most frequently words in a text
am 17.01.2008 19:39:59 von buzonHello everybody,
I am creating an algorithm to identify the most frequently words on =20
different sentences, using the following code:
// store in $arr_frequencyids all different words
for($i=3D0; $i
// use a hash using words as keys, and increment as frequency
for ($i=3D0; $i
$str_thisword =3D $arr_frequencywords[$i];
$hash_frequencywords[$str_thisword]++;
}
// descendent sort based on values
arsort($hash_frequencywords);
// store in $arr_20mostusedwords the 20 most frequent words
$arr_20mostusedwords =3D array_slice(array_keys($hash_frequencywords,0,20));
But... is not working. It is not counting the ocurrences. It stores as =20
a long string, even I used explode or trying a direct array addition =20
(arr1 +=3D arr2).
Warning: Wrong parameter count for array_keys() in =20
/home/mipyme/public_html/jpanel/index.php on line 204
Warning: Wrong parameter count for array_slice() in =20
/home/mipyme/public_html/jpanel/index.php on line 204
Warning: array_slice() [function.array-slice]: The first argument =20
should be an array in /home/mipyme/public_html/jpanel/index.php on =20
line 205
Could you give me some direction? (the information comes from a DB, =20
but for simplifying process I asume an array instead a while DB fetch =20
row)
Thank you,
Alejandro
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php