Guest User

Untitled

a guest
Jul 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. use Data::Dumper;
  3.  
  4. open(DATA,'/tmp/wordcloud');
  5. while($line=<DATA>){
  6. @words=split(/\s+/,$line);
  7. foreach $word (@words){
  8. $word=~s/[\.!,?:;]+$//; # strip off punctuation
  9. $count->{$word}++; } # increment the count of each word
  10. }
  11. close(DATA);
  12.  
  13. foreach $w (keys(%{ $count })){
  14. push(@{ $sorted->[ $count->{$w} ] }, $w);#assemble words with the same count
  15. }
  16.  
  17. $current=0;
  18. $max=100;
  19. for( $i=$#{$sorted}; $i>0; $i--){
  20. if(defined($sorted->[$i])){
  21. print "$i: ".join(" ",@{ $sorted->[$i] })."\n";
  22. $current++;
  23. if($current>=$max){ $i=0;}
  24. }
  25. };
Add Comment
Please, Sign In to add comment