From 9d5aaf992e6de183b7e8772a6c228e98b9914193 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Fri, 4 Aug 2017 12:49:10 +0200 Subject: hist-tok --- hist-tok | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 hist-tok (limited to 'hist-tok') 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]}" +} + -- cgit v1.2.3