Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created October 9, 2009 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitode909/206185 to your computer and use it in GitHub Desktop.
Save hitode909/206185 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby1.9
# -*- coding: utf-8 -*-
require 'ripper'
result = Hash.new{ |h,k| h[k] = 0 }
ARGF.read.split(/\s/).each{ |file|
Ripper.tokenize(open(file, "r:utf-8").read).each{ |token|
result[token] += 1
}
}
result.to_a.sort_by{ |pair| pair[1] }.reverse.each{ |pair|
token, count = *pair
puts "#{count} #{token.inspect}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment