Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created August 6, 2014 02:58
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 kaityo256/c7cfeabc5079e4204f0b to your computer and use it in GitHub Desktop.
Save kaityo256/c7cfeabc5079e4204f0b to your computer and use it in GitHub Desktop.
# -*- encoding: utf-8 -*-
require "rexml/document"
doc = nil
filename = ARGV[0]
if ARGV.size == 0
puts "usage: ruby title.rb projects.xml"
exit
end
File.open(filename) {|fp|
doc = REXML::Document.new fp
}
h = Hash.new
h.default = 0
i = 0
doc.root.elements.each {|e|
t = REXML::XPath.first(e,"title")
next if t == nil
if t.text =~ /.*\p{Hiragana}(.*)$/
h[$1] = h[$1] + 1
end
}
h.to_a.sort{|a,b| (a[1] <=> b[1])}.each{|a|
puts "#{a[0]} #{a[1]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment