annotate xml2txt.rb @ 6:e2337cd691b1 tip

Finishing writing the matlab code to replicate all observations made in the article. Added the article to the repository. Renamed the two main scripts ("1-get_mirex_estimates.rb" and "2-generate_smith2013_ismir.m") to not have dashes (since this was annoying within Matlab) Added new Michael Jackson figure.
author Jordan Smith <jordan.smith@eecs.qmul.ac.uk>
date Wed, 05 Mar 2014 01:02:26 +0000
parents 624231da830b
children
rev   line source
jordan@2 1 require 'xmlsimple'
jordan@2 2
jordan@2 3 # Script to convert Ewald Peiszer's XML annotations to my TXT format annotations.
jordan@2 4
jordan@2 5 a = XmlSimple.xml_in(ARGV[0])
jordan@2 6 rows = []
jordan@2 7 a["segmentation"][0]["segment"].each do |item|
jordan@2 8 rows << [item["start_sec"],item["label"]].join("\t")
jordan@2 9 end
jordan@2 10 rows << [a["segmentation"][0]["segment"][-1]["end_sec"],"end"].join("\t")
jordan@2 11
jordan@2 12 if ARGV[1].nil? then
jordan@2 13 filename = ARGV[0].split(".")[0..-2].join(".")
jordan@2 14 else
jordan@2 15 filename = ARGV[1].chomp
jordan@2 16 end
jordan@2 17
jordan@2 18 c = File.open(filename+".txt",'w')
jordan@2 19 c.write(rows)
jordan@2 20 c.close