view 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
line wrap: on
line source
require 'xmlsimple'

# Script to convert Ewald Peiszer's XML annotations to my TXT format annotations.

a = XmlSimple.xml_in(ARGV[0])
rows = []
a["segmentation"][0]["segment"].each do |item|
    rows << [item["start_sec"],item["label"]].join("\t")
end
rows << [a["segmentation"][0]["segment"][-1]["end_sec"],"end"].join("\t")

if ARGV[1].nil? then
    filename = ARGV[0].split(".")[0..-2].join(".")
else
    filename = ARGV[1].chomp
end

c = File.open(filename+".txt",'w')
c.write(rows)
c.close