Mercurial > hg > mirex-meta-analysis
changeset 5:8d896eec680e
Updated 1-get_mirex_estimates.rb to be compatible with Ruby 2.1.
Added .mat files to the package.
Other small fixes.
author | Jordan Smith <jordan.smith@eecs.qmul.ac.uk> |
---|---|
date | Sat, 22 Feb 2014 21:25:43 +0000 |
parents | 92b5a46bc67b |
children | e2337cd691b1 |
files | 1-get_mirex_estimates.rb 2-generate_smith2013_ismir.m datacubes.mat match_mirex_to_public_data_results.mat readme.txt |
diffstat | 5 files changed, 28 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/1-get_mirex_estimates.rb Sat Dec 07 18:18:50 2013 +0000 +++ b/1-get_mirex_estimates.rb Sat Feb 22 21:25:43 2014 +0000 @@ -4,14 +4,20 @@ mirex_path = "/Users/jordan/Desktop/MIREX_data" # EDIT THIS TO BE YOUR OWN DESIRED PATH. # IT WILL NEED TO HOLD ROUGHLY 70 MB OF DATA. + +# tmp = File.open(filename,'w') +# tmptxt = [] +# open(uri) {|f| +# f.each_line {|line| tmptxt.push(line)} +# } +# tmp.write(tmptxt) +# tmp.close +# + def url_download(uri, filename=".") - tmp = File.open(filename,'w') - tmptxt = [] - open(uri) {|f| - f.each_line {|line| tmptxt.push(line)} - } - tmp.write(tmptxt) - tmp.close + open(filename, 'w') do |foo| + foo.print open(uri).read + end end def convert_file(filename) @@ -20,8 +26,9 @@ ann_out = File.open(ann_out_file,'w') alg_out = File.open(alg_out_file,'w') text = File.open(filename,'r').readlines[1..-4].join("").split(/[\[\]]/) - ann = text[1] - alg = text[3] + text = File.open(filename,'r').readlines(sep=",").join("").split(/[\[\]]/) + ann = text[2].split(/[\{\}]/) + alg = text[4].split(/[\{\}]/) ann_out.write(json_2_text(ann)) alg_out.write(json_2_text(alg)) ann_out.close @@ -30,8 +37,8 @@ def json_2_text(json) txt = [] - json = json.split("\n") - json.each do |line| + (1..json.length).step(2).to_a.each do |indx| + line = json[indx] els = line.split(",") # Make a LAB-style annotation (3-column): # txt.push([els[0].split(" ")[-1].to_f, els[1].split(" ")[-1].to_f, els[2].split("\"")[-1]].join("\t")) @@ -52,6 +59,7 @@ puts "Thanks for starting the script! Stay tuned for periodic updates." # Create appropriate directory tree and download CSV files: +Dir.mkdir(mirex_path) unless File.directory?(mirex_path) puts("Downloading CSV files...\n") datasets.each do |dset| # Make dataset directory: @@ -63,7 +71,7 @@ Dir.mkdir(algo_path) unless File.directory?(algo_path) # Download the CSV file to this directory: algocsvpath = File.join(mirex_path,dset,algo,"per_track_results.csv") - csv_path = File.join("http://nema.lis.illinois.edu/nema_out/mirex",year,"/results/struct",dset,algo,"per_track_results.csv") + csv_path = File.join(("http://nema.lis.illinois.edu/nema_out/mirex"+year),"/results/struct",dset,algo,"per_track_results.csv") url_download(csv_path, algocsvpath) end end @@ -78,11 +86,12 @@ algos.each do |algo| puts( "Starting to download "+dset+ " dataset for " + algo + " algorithm...\n") algocsvpath = File.join(mirex_path,dset,algo,"per_track_results.csv") - csv_data = CSV.read(algocsvpath) + csv_data = File.read(algocsvpath).split("\n") header = csv_data.delete_at(0) download_folder = File.join(mirex_path,dset,algo) # For each line in the spreadsheet, extract the songid and download the corresponding json document. csv_data.each do |line| + line = line.split(",") song_id = line[1] url = "http://nema.lis.illinois.edu/nema_out/mirex" + year + "/results/struct/" + dset + "/" + algo.downcase + "segments" + song_id.delete("_") + ".js" download_path = File.join(download_folder,song_id + ".js") @@ -111,7 +120,7 @@ # # # # PART 2: GET (AND CONVERT) THE ANNOTATION DATA PUBLISHED BY OTHERS # Download and unzip all public annotations -list_of_db_urls = ["http://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-P-2001.CHORUS.zip", "http://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-C-2001.CHORUS.zip", "http://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-J-2001.CHORUS.zip", "http://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-G-2001.CHORUS.zip", "http://www.music.mcgill.ca/~jordan/salami/releases/SALAMI_data_v1.2.zip", "http://www.ifs.tuwien.ac.at/mir/audiosegmentation/dl/ep_groundtruth_excl_Paulus.zip", "http://musicdata.gforge.inria.fr/IRISA.RWC-MDB-P-2012.SEMLAB_v003_full.zip", "http://musicdata.gforge.inria.fr/IRISA.RWC-MDB-P-2012.SEMLAB_v003_reduced.zip", "http://musicdata.gforge.inria.fr/IRISA.RWC-MDB-P-2001.BLOCKS_v001.zip", "http://www.isophonics.net/files/annotations/The%20Beatles%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Carole%20King%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Queen%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Michael%20Jackson%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Zweieck%20Annotations.tar.gz", "http://www.cs.tut.fi/sgn/arg/paulus/beatles_sections_TUT.zip", "http://www.iua.upf.edu/~perfe/annotations/sections/beatles/structure_Beatles.rar"] +list_of_db_urls = ["https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-P-2001.CHORUS.zip", "https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-C-2001.CHORUS.zip", "https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-J-2001.CHORUS.zip", "https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-G-2001.CHORUS.zip", "http://www.music.mcgill.ca/~jordan/salami/releases/SALAMI_data_v1.2.zip", "http://www.ifs.tuwien.ac.at/mir/audiosegmentation/dl/ep_groundtruth_excl_Paulus.zip", "http://musicdata.gforge.inria.fr/IRISA.RWC-MDB-P-2012.SEMLAB_v003_full.zip", "http://musicdata.gforge.inria.fr/IRISA.RWC-MDB-P-2012.SEMLAB_v003_reduced.zip", "http://musicdata.gforge.inria.fr/IRISA.RWC-MDB-P-2001.BLOCKS_v001.zip", "http://www.isophonics.net/files/annotations/The%20Beatles%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Carole%20King%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Queen%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Michael%20Jackson%20Annotations.tar.gz", "http://www.isophonics.net/files/annotations/Zweieck%20Annotations.tar.gz", "http://www.cs.tut.fi/sgn/arg/paulus/beatles_sections_TUT.zip", "http://www.iua.upf.edu/~perfe/annotations/sections/beatles/structure_Beatles.rar"] public_data_path = File.join(mirex_path,"public_data") Dir.mkdir(public_data_path) unless File.directory?(public_data_path)
--- a/2-generate_smith2013_ismir.m Sat Dec 07 18:18:50 2013 +0000 +++ b/2-generate_smith2013_ismir.m Sat Feb 22 21:25:43 2014 +0000 @@ -25,6 +25,8 @@ % You should get a copy of the evalution scripts in the Code.SoundSoftware % repository. Wherever you put it, set the following path accordingly: addpath('/Users/me/Desktop/whereiputmymatlabfiles/structural_analysis_evaluation') +% You should also, clearly, add the current path (where this file is): +addpath('.') % Check that we have access to the correct dependencies.
--- a/readme.txt Sat Dec 07 18:18:50 2013 +0000 +++ b/readme.txt Sat Feb 22 21:25:43 2014 +0000 @@ -17,7 +17,7 @@ >> In "2-generate_smith2013_ismir", set the exact same path >> In "2-generate_smith2013_ismir", set the path for the "structural analysis evaluation" repository -4. Run the Ruby script "1-get_mirex_estimates.rb" and wait a while for all the data to download. +4. Run the Ruby script "1-get_mirex_estimates.rb" and wait a while for all the data to download. Alternatively, because this takes a long time, just unzip the contents of the included MIREX_DATA.zip file. 5. Unzip all the folders that you obtained. Note: in this version, one of the repositories, the Ewald Peiszer repository, is included already as a zip file ("ep_groundtruth_txt.zip"). If you set "./mirex_data" as the download path in Step 3, then just unzip it here. Otherwise, move it to wherever the rest of the zips are. @@ -32,6 +32,8 @@ 1. Bug in how CSV files are parsed in Ruby v.1.9.3. Seems to work fine using an older version: try 1.8.7. +1.1. In January 2014, the code was updated to work with Ruby v.2.1. + ===== Ground Truth Directory map =====