From: Richard Kojedzinszky Date: Mon, 6 Oct 2014 21:23:12 +0000 (+0200) Subject: uwc: ruby implementation X-Git-Url: http://git.neszt.hu/?a=commitdiff_plain;h=0cc20f0516969fe4fa1c5f807b921e2eabd80374;p=uwc.git uwc: ruby implementation --- diff --git a/uwc.rb b/uwc.rb new file mode 100644 index 0000000..38deebb --- /dev/null +++ b/uwc.rb @@ -0,0 +1,16 @@ +#!/usr/bin/ruby -w + +hash = Hash.new(0) + +re = /([a-z']+)/i + +$stdin.each do |line| + line.scan(re).each do |w| + w = w[0] + hash[w] = hash[w] + 1 + end +end + +hash.keys.sort_by! { |x| [hash[x], x] }.each do |w| + puts "#{w} #{hash[w]}" +end