Skip to content

Instantly share code, notes, and snippets.

@judofyr
Forked from kitallis/word_histogram.rb
Created August 15, 2009 09:54
Show Gist options
  • Save judofyr/168321 to your computer and use it in GitHub Desktop.
Save judofyr/168321 to your computer and use it in GitHub Desktop.
# Creates a little histogram of the frequency of words occuring in your string
# Usage : ruby word_histogram.rb "Test string, string"
h=Hash.new(m=0);ARGV[m].scan(/\w+/).map{|x|h[x.downcase]+=1;m=[m,x.size].max};h.sort.map{|k,v|puts"=> %-#{m+4}s#{'*'*v}"%k}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment