Created
February 24, 2013 13:39
-
-
Save quwubin/5023882 to your computer and use it in GitHub Desktop.
Parse and statistics Medline (PubMed) abstract files
This file contains hidden or 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
require 'bio' | |
# Input is abstract file in Medline format. | |
year_count = Hash.new(0) | |
File.read(ARGV[0]).split("\n\n").each do |article_block| | |
article = Bio::MEDLINE.new(article_block) | |
year_count[article.year] += 1 | |
end | |
year_count.each do |year, count| | |
puts "#{year}, #{count}" | |
end | |
p year_count.values.inject{|sum, x| sum + x} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment