summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2017-08-04 12:49:10 +0200
committerPatrick Simianer <p@simianer.de>2017-08-04 12:49:10 +0200
commit9d5aaf992e6de183b7e8772a6c228e98b9914193 (patch)
tree28c37caaf153b8db6d4df32131930a73d2e2d18b
parent6ebbb48f8d167464e30d6b39c19991f13db342ac (diff)
hist-tok
-rw-r--r--hist-tok24
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]}"
+}
+