word count
- Started
- Last post
- 9 Responses
- gimmejimmy
looking for a program that will count the instances of words in a document and sort them accordingly. kind of like a tag cloud generator...
I'm not sure what to google to find this
- fiver0
34
- i_monk0
For print or web use?
- gimmejimmy0
either
- akrok0
"sort them accordingly" lol.
- stoplying0
Jimmy doesn't like to count words.
- lukus_W0
What are you actually trying to do?
- detritus0
hrm, I typed in
javascript count sort unique words
into Google and already came up with some options.
What's the problem?
- squidbrains0
doesn't account for punctuation. doesn't sub-sort the words with same frequency.
$file = file_get_contents('./lotta_words... true);
$words = explode(' ', $file);
$counts = array();
foreach($words as $word) {
if ( ! isset($counts[$word])) {
$counts["$word"] = 1;
} else {
$counts["$word"]++;
}
}
asort($counts);foreach($counts as $word => $count) {
echo "$word : $count<br />";
}
- transmission0
you can try the app. it has an function that lists word frequencies.