diff options
-rw-r--r-- | hist-tok | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/hist-tok b/hist-tok new file mode 100644 index 0000000..b81604f --- /dev/null +++ b/hist-tok @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby + +counts = {} +counts.default = 0 +while line = STDIN.gets + toks = line.strip.split + toks.each { |tok| + counts[tok] += 1 + } +end + +sorted = [] +counts.each_pair { |k,v| + sorted << [k,v] +} + +sorted.sort_by! { |i| + -i[1] +} + +sorted.each { |i| + puts "#{i[0]}\t#{i[1]}" +} + |