Mercurial > hg > webaudioevaluationtool
comparison scripts/evaluation_stats.py @ 1065:b2492aeafe8b
Scripts: show which and how many markers not clicked or moved; option to plot timelines against 'audioholder time' (default) or 'total test time' (previously the only possibility)
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Mon, 10 Aug 2015 18:45:45 +0200 |
parents | 99cb3436759e |
children | 235594325b84 |
comparison
equal
deleted
inserted
replaced
1064:99cb3436759e | 1065:b2492aeafe8b |
---|---|
27 # stats initialisation | 27 # stats initialisation |
28 number_of_XML_files = 0 | 28 number_of_XML_files = 0 |
29 number_of_pages = 0 | 29 number_of_pages = 0 |
30 number_of_fragments = 0 | 30 number_of_fragments = 0 |
31 total_empty_comments = 0 | 31 total_empty_comments = 0 |
32 total_not_played = 0 | |
33 total_not_moved = 0 | |
32 time_per_page_accum = 0 | 34 time_per_page_accum = 0 |
33 | 35 |
34 # arrays initialisation | 36 # arrays initialisation |
35 page_names = [] | 37 page_names = [] |
36 page_count = [] | 38 page_count = [] |
60 print "WARNING: " + file + " contains empty audio holder. (evaluation_stats.py)" | 62 print "WARNING: " + file + " contains empty audio holder. (evaluation_stats.py)" |
61 break # move on to next | 63 break # move on to next |
62 | 64 |
63 number_of_comments = 0 # for this page | 65 number_of_comments = 0 # for this page |
64 number_of_missing_comments = 0 # for this page | 66 number_of_missing_comments = 0 # for this page |
67 not_played = 0 # for this page | |
68 not_moved = 0 # for this page | |
69 | |
70 # 'testTime' keeps total duration: subtract time so far for duration of this audioholder | |
71 duration = float(audioholder.find("./metric/metricresult[@id='testTime']").text) - total_duration | |
72 | |
73 # total duration of test | |
74 total_duration += duration | |
65 | 75 |
66 # number of audio elements | 76 # number of audio elements |
67 audioelements = audioholder.findall("./audioelement") # get audioelements | 77 audioelements = audioholder.findall("./audioelement") # get audioelements |
68 number_of_fragments += len(audioelements) # add length of this list to total | 78 number_of_fragments += len(audioelements) # add length of this list to total |
69 | 79 |
70 # number of comments (interesting if comments not mandatory) | 80 # number of comments (interesting if comments not mandatory) |
71 for audioelement in audioelements: | 81 for audioelement in audioelements: |
72 response = audioelement.find("./comment/response") | 82 response = audioelement.find("./comment/response") |
83 was_played = audioelement.find("./metric/metricresult/[@name='elementFlagListenedTo']") | |
84 was_moved = audioelement.find("./metric/metricresult/[@name='elementFlagMoved']") | |
73 if response.text is not None and len(response.text) > 1: | 85 if response.text is not None and len(response.text) > 1: |
74 number_of_comments += 1 | 86 number_of_comments += 1 |
75 else: | 87 else: |
76 number_of_missing_comments += 1 | 88 number_of_missing_comments += 1 |
77 | 89 if was_played is not None and was_played.text == 'false': |
90 not_played += 1 | |
91 if was_moved is not None and was_moved.text == 'false': | |
92 not_moved += 1 | |
93 | |
94 # update global counters | |
78 total_empty_comments += number_of_missing_comments | 95 total_empty_comments += number_of_missing_comments |
79 | 96 total_not_played += not_played |
80 # 'testTime' keeps total duration: subtract time so far for duration of this audioholder | 97 total_not_moved += not_moved |
81 duration = float(audioholder.find("./metric/metricresult[@id='testTime']").text) - total_duration | |
82 | |
83 # total duration of test | |
84 total_duration += duration | |
85 | 98 |
86 # print audioholder id and duration | 99 # print audioholder id and duration |
87 print " " + page_name + ": " + seconds2timestr(duration) + ", "\ | 100 print " " + page_name + ": " + seconds2timestr(duration) + ", "\ |
88 + str(number_of_comments)+"/"\ | 101 + str(number_of_comments)+"/"\ |
89 +str(number_of_comments+number_of_missing_comments)+" comments" | 102 +str(number_of_comments+number_of_missing_comments)+" comments" |
103 | |
104 # number of audio elements not played | |
105 if not_played > 1: | |
106 print 'ATTENTION: '+str(not_played)+' fragments were not listened to!' | |
107 if not_played == 1: | |
108 print 'ATTENTION: one fragment was not listened to!' | |
109 | |
110 # number of audio element markers not moved | |
111 if not_moved > 1: | |
112 print 'ATTENTION: '+str(not_moved)+' markers were not moved!' | |
113 if not_moved == 1: | |
114 print 'ATTENTION: one marker was not moved!' | |
90 | 115 |
91 # keep track of duration in function of page index | 116 # keep track of duration in function of page index |
92 if len(duration_order)>page_number: | 117 if len(duration_order)>page_number: |
93 duration_order[page_number].append(duration) | 118 duration_order[page_number].append(duration) |
94 else: | 119 else: |
132 # PRINT EVERYTHING | 157 # PRINT EVERYTHING |
133 | 158 |
134 print "Number of XML files: " + str(number_of_XML_files) | 159 print "Number of XML files: " + str(number_of_XML_files) |
135 print "Number of pages: " + str(number_of_pages) | 160 print "Number of pages: " + str(number_of_pages) |
136 print "Number of fragments: " + str(number_of_fragments) | 161 print "Number of fragments: " + str(number_of_fragments) |
137 print "Number of empty comments: " + str(total_empty_comments) | 162 print "Number of empty comments: " + str(total_empty_comments) +\ |
163 " (" + str(round(100.0*total_empty_comments/number_of_fragments,2)) + "%)" | |
164 print "Number of unplayed fragments: " + str(total_not_played) +\ | |
165 " (" + str(round(100.0*total_not_played/number_of_fragments,2)) + "%)" | |
166 print "Number of unmoved markers: " + str(total_not_moved) +\ | |
167 " (" + str(round(100.0*total_not_moved/number_of_fragments,2)) + "%)" | |
138 print "Average time per page: " + seconds2timestr(time_per_page_accum/number_of_pages) | 168 print "Average time per page: " + seconds2timestr(time_per_page_accum/number_of_pages) |
139 | 169 |
140 # Pages and number of times tested | 170 # Pages and number of times tested |
141 page_count_strings = list(str(x) for x in page_count) | 171 page_count_strings = list(str(x) for x in page_count) |
142 count_list = page_names + page_count_strings | 172 count_list = page_names + page_count_strings |
143 count_list[::2] = page_names | 173 count_list[::2] = page_names |
144 count_list[1::2] = page_count_strings | 174 count_list[1::2] = page_count_strings |
145 print "Pages tested: " + str(count_list) | 175 print "Pages tested: " + str(count_list) |
146 | 176 |
147 # Average duration for first, second, ... page | 177 # Average duration for first, second, ... page |
178 print "Average duration per page:" | |
148 for page_number in range(len(duration_order)): | 179 for page_number in range(len(duration_order)): |
149 print "Average duration page " + str(page_number+1) + ": " +\ | 180 print " page " + str(page_number+1) + ": " +\ |
150 seconds2timestr(sum(duration_order[page_number])/len(duration_order[page_number])) +\ | 181 seconds2timestr(sum(duration_order[page_number])/len(duration_order[page_number])) +\ |
151 " ("+str(len(duration_order[page_number]))+" subjects)" | 182 " ("+str(len(duration_order[page_number]))+" subjects)" |
152 | 183 |
153 | 184 |
154 # Sort pages by number of audioelements, then by duration | 185 # Sort pages by number of audioelements, then by duration |
163 # combine and sort in function of number of audioelements and duration | 194 # combine and sort in function of number of audioelements and duration |
164 combined_list = [page_names, average_duration_page, fragments_per_page, number_of_subjects_page] | 195 combined_list = [page_names, average_duration_page, fragments_per_page, number_of_subjects_page] |
165 combined_list = sorted(zip(*combined_list), key=operator.itemgetter(1, 2)) # sort | 196 combined_list = sorted(zip(*combined_list), key=operator.itemgetter(1, 2)) # sort |
166 | 197 |
167 # Show average duration for all songs | 198 # Show average duration for all songs |
199 print "Average duration per audioholder:" | |
168 for page_index in range(len(page_names)): | 200 for page_index in range(len(page_names)): |
169 print "Average duration audioholder " + combined_list[page_index][0] + ": " \ | 201 print " "+combined_list[page_index][0] + ": " \ |
170 + seconds2timestr(combined_list[page_index][1]) \ | 202 + seconds2timestr(combined_list[page_index][1]) \ |
171 + " (" + str(combined_list[page_index][3]) + " subjects, " \ | 203 + " (" + str(combined_list[page_index][3]) + " subjects, " \ |
172 + str(combined_list[page_index][2]) + " fragments)" | 204 + str(combined_list[page_index][2]) + " fragments)" |
173 | 205 |
174 | 206 |
178 # plot total time for each participant | 210 # plot total time for each participant |
179 # plot total time | 211 # plot total time |
180 # show 'count' per page (in order) | 212 # show 'count' per page (in order) |
181 | 213 |
182 # clear up page_index <> page_count <> page_number confusion | 214 # clear up page_index <> page_count <> page_number confusion |
215 | |
216 # LaTeX -> PDF print out |