Created
March 19, 2009 09:09
-
-
Save leandro/81662 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RIndexer | |
RE_TAG = %r!<([a-z\d_-]+)\s*.*?>!im | |
def fetch_tags(doc_stream) | |
tags = Hash.new(0) | |
doc_stream.scan(RE_TAG).each do |e| | |
tags[e] += 1 | |
end | |
tags | |
end | |
end | |
include RIndexer | |
arg = ARGV.shift | |
fetch_tags(IO.read(arg)).sort {|a,b| b[1] <=> a[1]}.each {|e| puts "#{e[0]} => #{e[1]}"} | |
#USAGE: ruby teste.rb document.xml (or html, etc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment