changeset 261:7bdc95a1fbd1

Scripts: evaluation_stats shows number of total fragments
author Brecht De Man <b.deman@qmul.ac.uk>
date Tue, 14 Jul 2015 19:40:58 +0100
parents be08f0bc3f31
children edc386c86c86
files scripts/evaluation_stats.py
diffstat 1 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/evaluation_stats.py	Fri Jul 03 21:01:09 2015 +0100
+++ b/scripts/evaluation_stats.py	Tue Jul 14 19:40:58 2015 +0100
@@ -5,7 +5,7 @@
 import os
 
 # XML results files location (modify as needed):
-folder_name = "../saves"    # Looks in 'saves/' folder from 'scripts/' folder
+folder_name = "xml_with_statements"    # Looks in 'saves/' folder from 'scripts/' folder
 
 # Turn number of seconds (int) to '[minutes] min [seconds] s' (string)
 def seconds2timestr(time_in_seconds):
@@ -16,6 +16,7 @@
 # stats initialisation
 number_of_XML_files = 0
 number_of_pages = 0
+number_of_fragments = 0
 time_per_page_accum = 0
 
 # arrays initialisation
@@ -46,12 +47,12 @@
             if page_name is None: # ignore 'empty' audio_holders
                 print "WARNING: " + file + " contains empty audio holder. (evaluation_stats.py)"
                 break # move on to next
-                
+            
             # keep list of audioholder ids and count how many times each audioholder id was tested
             if page_name in page_names:
                 page_index = page_names.index(page_name) # get index
                 page_count[page_index] += 1
-            else: 
+            else:
                 page_names.append(page_name)
                 page_count.append(1)
             
@@ -69,18 +70,24 @@
                 duration_order[page_number].append(duration)
             else:
                 duration_order.append([duration])
+
+            # number of audio elements
+            audioelements = audioholder.findall("./audioelement") # get audioelements
+            number_of_fragments += len(audioelements) # add length of this list to total
             
             page_number += 1 # increase page count for this specific test
             number_of_pages += 1 # increase total number of pages
             time_per_page_accum += duration # total duration (for average time spent per page)
-        
-        # print total duration of this test
-        print "    TOTAL: " + seconds2timestr(total_duration)
-                    
+
+    # print total duration of this test
+    print "    TOTAL: " + seconds2timestr(total_duration)
+
+
 # PRINT EVERYTHING
 
 print "Number of XML files: " + str(number_of_XML_files)
 print "Number of pages: " + str(number_of_pages)
+print "Number of fragments: " + str(number_of_fragments)
 print "Average time per page: " + seconds2timestr(time_per_page_accum/number_of_pages)
 page_count_strings = list(str(x) for x in page_count)
 count_list = page_names + page_count_strings
@@ -91,15 +98,15 @@
 # Average duration for first, second, ... page
 for page_number in range(len(duration_order)): #TODO make maximum page number automatic
     print "Average duration page " + str(page_number+1) + ": " +\
-          seconds2timestr(sum(duration_order[page_number])/len(duration_order[page_number])) +\
-          " ("+str(len(duration_order[page_number]))+" subjects)"
-          
+        seconds2timestr(sum(duration_order[page_number])/len(duration_order[page_number])) +\
+            " ("+str(len(duration_order[page_number]))+" subjects)"
+
 
 #TODO
 # time per page in function of number of fragments (plot)
 # time per participant in function of number of pages
 # plot total time for each participant
-# plot total time 
+# plot total time
 # show 'count' per page (in order)
 
 # clear up page_index <> page_count <> page_number confusion