Mercurial > hg > webaudioevaluationtool
changeset 245:fc056b63e208
Readme: reference to issue tracker; Scripts: comment_parser and score_parser read and write in '/saves' from 'scripts/', condensing XML queries (references from children instead of from root)
author | Brecht De Man <b.deman@qmul.ac.uk> |
---|---|
date | Mon, 29 Jun 2015 13:15:00 +0100 |
parents | eff3dfc433ae |
children | 83584c6b09b5 |
files | README.txt scripts/comment_parser.py scripts/score_boxplot.py scripts/score_parser.py |
diffstat | 4 files changed, 57 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/README.txt Sun Jun 28 10:33:47 2015 +0100 +++ b/README.txt Mon Jun 29 13:15:00 2015 +0100 @@ -58,6 +58,8 @@ FEATURE REQUESTS AND BUG REPORTS +We continually develop this tool to fix issues and implement features useful to us or our user base. See https://code.soundsoftware.ac.uk/projects/webaudioevaluationtool/issues for a list of feature requests and bug reports, and their status. + Please contact the authors if you experience any bugs, if you would like additional functionality, if you have questions about using the interface or if you would like to give any feedback (even positive!) about the interface. We look forward to learning how the tool has (not) been useful to you.
--- a/scripts/comment_parser.py Sun Jun 28 10:33:47 2015 +0100 +++ b/scripts/comment_parser.py Mon Jun 29 13:15:00 2015 +0100 @@ -5,10 +5,13 @@ import os import csv +# XML results files location (modify as needed): +folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder + # get every XML file in folder -for file in os.listdir("."): # You have to put this script in folder where output XML files are. +for file in os.listdir(folder_name): if file.endswith(".xml"): - tree = ET.parse(file) + tree = ET.parse(folder_name + '/' + file) root = tree.getroot() # get list of all page names @@ -19,16 +22,15 @@ break # create folder [page_name] if not yet created - if not os.path.exists(page_name): - os.makedirs(page_name) + if not os.path.exists(folder_name + "/" + page_name): + os.makedirs(folder_name + "/" + page_name) # for page [page_name], print comments related to fragment [id] - for audioelement in root.findall("*/[@id='"+page_name+"']/audioelement"): #TODO in audioholder.findall(...) + for audioelement in audioholder.findall("./audioelement"): if audioelement is not None: # Check it exists audio_id = str(audioelement.get('id')) - - csv_name = page_name+'/'+page_name+'-comments-'+audio_id+'.csv' + csv_name = folder_name +'/' + page_name+'/'+page_name+'-comments-'+audio_id+'.csv' # append (!) to file [page_name]/[page_name]-comments-[id].csv with open(csv_name, 'a') as csvfile: @@ -36,18 +38,15 @@ delimiter=',', dialect="excel", quoting=csv.QUOTE_ALL) - commentstr = root.find("*/[@id='" - + page_name - + "']/audioelement/[@id='" - + audio_id - + "']/comment/response").text + commentstr = audioelement.find("./comment/response").text + if commentstr is None: - writer.writerow(['']) - else: - # anonymous comments: - writer.writerow([commentstr.encode("utf-8")]) - # comments with (file) name: - #writer.writerow([file[:-4]] + [commentstr.encode("utf-8")]) + commentstr = ''; + + # anonymous comments: + #writer.writerow([commentstr.encode("utf-8")]) + # comments with (file) name: + writer.writerow([file[:-4]] + [commentstr.encode("utf-8")]) #TODO Replace 'new line' in comment with something else?
--- a/scripts/score_boxplot.py Sun Jun 28 10:33:47 2015 +0100 +++ b/scripts/score_boxplot.py Mon Jun 29 13:15:00 2015 +0100 @@ -30,34 +30,34 @@ # draw boxplot plt.boxplot(ratings) - - if not show_individual: - # add rating of individual(s) - with open(rating_folder+file, 'r') as readfile: # read this csv file - filereader = csv.reader(readfile, delimiter=',') - headerrow = filereader.next() # use headerrow as X-axis - headerrow = headerrow[1:] - markerlist = ["x", ".", "o", "*", "+", "v", ">", "<", "8", "s", "p"] - increment = 0 - linehandles = [] - legendnames = [] - for row in filereader: - subject_id = row[0][:-4] - if subject_id in show_individual: - plothandle, = plt.plot(range(1,len(row)), # x-values - row[1:], # y-values: csv values except subject name - color='k', - marker=markerlist[increment%len(markerlist)], - markersize=10, - linestyle='None', - label=subject_id - ) - increment += 1 # increase counter - linehandles.append(plothandle) - legendnames.append(subject_id) - plt.legend(linehandles, legendnames, - loc='upper right', - bbox_to_anchor=(1.1, 1), borderaxespad=0.) + + if not show_individual: + # add rating of individual(s) + with open(rating_folder+file, 'r') as readfile: # read this csv file + filereader = csv.reader(readfile, delimiter=',') + headerrow = filereader.next() # use headerrow as X-axis + headerrow = headerrow[1:] + markerlist = ["x", ".", "o", "*", "+", "v", ">", "<", "8", "s", "p"] + increment = 0 + linehandles = [] + legendnames = [] + for row in filereader: + subject_id = row[0][:-4] + if subject_id in show_individual: + plothandle, = plt.plot(range(1,len(row)), # x-values + row[1:], # y-values: csv values except subject name + color='k', + marker=markerlist[increment%len(markerlist)], + markersize=10, + linestyle='None', + label=subject_id + ) + increment += 1 # increase counter + linehandles.append(plothandle) + legendnames.append(subject_id) + plt.legend(linehandles, legendnames, + loc='upper right', + bbox_to_anchor=(1.1, 1), borderaxespad=0.) plt.xlabel('Fragment')
--- a/scripts/score_parser.py Sun Jun 28 10:33:47 2015 +0100 +++ b/scripts/score_parser.py Mon Jun 29 13:15:00 2015 +0100 @@ -4,10 +4,13 @@ #TODO Remove DEBUG statements +# XML results files location (modify as needed): +folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder + # get every XML file in folder -for file in os.listdir("."): # You have to put this in folder where output XML files are. +for file in os.listdir(folder_name): # You have to put this in folder where output XML files are. if file.endswith(".xml"): - tree = ET.parse(file) + tree = ET.parse(folder_name + '/' + file) root = tree.getroot() #print ["DEBUG Reading " + file + "..."] @@ -22,17 +25,17 @@ if page_name is None: # ignore 'empty' audio_holders break - file_name = 'ratings/'+page_name+'-ratings.csv' # score file name + file_name = folder_name+'/ratings/'+page_name+'-ratings.csv' # score file name # create folder 'ratings if not yet created - if not os.path.exists('ratings'): - os.makedirs('ratings') + if not os.path.exists(folder_name + '/ratings'): + os.makedirs(folder_name + '/ratings') # header: fragment IDs in 'alphabetical' order # go to fragment column, or create new column if it doesn't exist yet # get array of audio elements and number of audio elements - audiolist = root.findall("*/[@id='"+page_name+"']/audioelement") + audiolist = audioholder.findall("./audioelement") n_fragments = len(audiolist) # get alphabetical array of fragment IDs from this subject's XML @@ -85,9 +88,7 @@ # get scores related to fragment [id] for fragmentname in headerrow[1:]: # iterate over fragments in header (skip first empty column) - elementvalue = root.find("*/[@id='" - + page_name - + "']/audioelement/[@id='" + elementvalue = audioholder.find("./audioelement/[@id='" + fragmentname + "']/value") if hasattr(elementvalue, 'text'): # if rating for this fragment exists