Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use Data::Dumper;
- open(DATA,'/tmp/wordcloud');
- while($line=<DATA>){
- @words=split(/\s+/,$line);
- foreach $word (@words){
- $word=~s/[\.!,?:;]+$//; # strip off punctuation
- $count->{$word}++; } # increment the count of each word
- }
- close(DATA);
- foreach $w (keys(%{ $count })){
- push(@{ $sorted->[ $count->{$w} ] }, $w);#assemble words with the same count
- }
- $current=0;
- $max=100;
- for( $i=$#{$sorted}; $i>0; $i--){
- if(defined($sorted->[$i])){
- print "$i: ".join(" ",@{ $sorted->[$i] })."\n";
- $current++;
- if($current>=$max){ $i=0;}
- }
- };
Add Comment
Please, Sign In to add comment