changeset 2228:3358d04605db

Updated scripts to work with latest results document specification
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 14 Apr 2016 17:16:20 +0100
parents 43ab418ba4b8
children 555dc922aa79 4e334c942d41
files .gitignore scripts/comment_parser.py scripts/evaluation_stats.py scripts/timeline_view.py scripts/timeline_view_movement.py
diffstat 5 files changed, 50 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/.gitignore	Thu Apr 14 15:58:52 2016 +0100
+++ b/.gitignore	Thu Apr 14 17:16:20 2016 +0100
@@ -7,4 +7,4 @@
 *.out
 *.synctex.gz
 *.toc
-save/*.xml
\ No newline at end of file
+saves/*.xml
\ No newline at end of file
--- a/scripts/comment_parser.py	Thu Apr 14 15:58:52 2016 +0100
+++ b/scripts/comment_parser.py	Thu Apr 14 17:16:20 2016 +0100
@@ -42,43 +42,46 @@
         
         # get list of all page names
         for audioholder in root.findall("./page"):   # iterate over pages
-            page_name = audioholder.get('id')               # get page name
+            page_name = audioholder.get('ref')               # get page name
             
             if page_name is None: # ignore 'empty' audio_holders
                 print "WARNING: " + file + " contains empty page. (comment_parser.py)"
                 break
+                
+            if audioholder.get("state") != "complete":
+                print "WARNING: " + file + "test page " + page_name + " is not complete, skipping."
+            else :
+                # create folder [page_name] if not yet created
+                if not os.path.exists(folder_name + "/" + page_name):
+                    os.makedirs(folder_name + "/" + page_name)
 
-            # create folder [page_name] if not yet created
-            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 audioholder.findall("./audioelement"):
+                    if audioelement is not None: # Check it exists
+                        audio_id = str(audioelement.get('ref'))
 
-            # for page [page_name], print comments related to fragment [id]
-            for audioelement in audioholder.findall("./audioelement"):
-                if audioelement is not None: # Check it exists
-                    audio_id = str(audioelement.get('id'))
-                    
-                    csv_name = folder_name +'/' + page_name+'/'+page_name+'-comments-'+audio_id+'.csv'
+                        csv_name = folder_name +'/' + page_name+'/'+page_name+'-comments-'+audio_id+'.csv'
 
-                    # If file hasn't been opened yet this time, empty
-                    if csv_name not in file_history:
-                        csvfile = open(csv_name, 'w')
-                        file_history.append(csv_name) # remember this file has been written to this time around
-                    else: 
-                        # append (!) to file [page_name]/[page_name]-comments-[id].csv
-                        csvfile = open(csv_name, 'a')
-                    writer = csv.writer(csvfile, 
-                                        delimiter=',', 
-                                        dialect="excel",
-                                        quoting=csv.QUOTE_ALL)
-                    commentstr = audioelement.find("./comment/response").text
-                        
-                    if commentstr is None:
-                       commentstr = ''
-                        
-                    # anonymous comments:
-                    #writer.writerow([commentstr.encode("utf-8")]) 
-                    # comments with (file) name:
-                    writer.writerow([file[:-4]] + [commentstr.encode("utf-8")]) 
+                        # If file hasn't been opened yet this time, empty
+                        if csv_name not in file_history:
+                            csvfile = open(csv_name, 'w')
+                            file_history.append(csv_name) # remember this file has been written to this time around
+                        else: 
+                            # append (!) to file [page_name]/[page_name]-comments-[id].csv
+                            csvfile = open(csv_name, 'a')
+                        writer = csv.writer(csvfile, 
+                                            delimiter=',', 
+                                            dialect="excel",
+                                            quoting=csv.QUOTE_ALL)
+                        commentstr = audioelement.find("./comment/response").text
+
+                        if commentstr is None:
+                           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/evaluation_stats.py	Thu Apr 14 15:58:52 2016 +0100
+++ b/scripts/evaluation_stats.py	Thu Apr 14 17:16:20 2016 +0100
@@ -56,12 +56,14 @@
         
         # get list of all page names
         for audioholder in root.findall("./page"):   # iterate over pages
-            page_name = audioholder.get('id')               # get page name
+            page_name = audioholder.get('ref')               # get page name
             
             if page_name is None: # ignore 'empty' audio_holders
                 print "WARNING: " + file + " contains empty audio holder. (evaluation_stats.py)"
                 break # move on to next
-            
+            if audioholder.get("state") != "complete":
+                print "WARNING" + file + " contains incomplete audio holder."
+                break
             number_of_comments = 0 # for this page
             number_of_missing_comments = 0 # for this page
             not_played = 0 # for this page
--- a/scripts/timeline_view.py	Thu Apr 14 15:58:52 2016 +0100
+++ b/scripts/timeline_view.py	Thu Apr 14 17:16:20 2016 +0100
@@ -71,19 +71,23 @@
         # ONE TIMELINE PER PAGE - make new plot per page
 
         # get list of all page names
-        for audioholder in root.findall("./audioholder"):   # iterate over pages
-            page_name = audioholder.get('id')               # get page name
+        for audioholder in root.findall("./page"):   # iterate over pages
+            page_name = audioholder.get('ref')               # get page name
             plot_empty = True                               # check if any data is plotted
             
             if page_name is None: # ignore 'empty' audio_holders
+                print "WARNING: " + file + " contains empty page. (comment_parser.py)"
                 break
-
+                
+            if audioholder.get("state") != "complete":
+                print "WARNING: " + file + "test page " + page_name + " is not complete, skipping."
+                break;
             # SORT AUDIO ELEMENTS ALPHABETICALLY
             audioelements = audioholder.findall("./audioelement")
             
             data = []
             for elem in audioelements: # from http://effbot.org/zone/element-sort.htm
-                key = elem.get("id")
+                key = elem.get("ref")
                 data.append((key, elem))
             data.sort()
             
@@ -99,7 +103,7 @@
             for tuple in data:
                 audioelement = tuple[1]
                 if audioelement is not None: # Check it exists
-                    audio_id = str(audioelement.get('id'))
+                    audio_id = str(audioelement.get('ref'))
                     audioelements_names.append(audio_id)
                     
                     # for this audioelement, loop over all listen events
--- a/scripts/timeline_view_movement.py	Thu Apr 14 15:58:52 2016 +0100
+++ b/scripts/timeline_view_movement.py	Thu Apr 14 17:16:20 2016 +0100
@@ -68,7 +68,7 @@
 
         # get list of all page names
         for audioholder in root.findall("./page"):   # iterate over pages
-            page_name = audioholder.get('id')               # get page name
+            page_name = audioholder.get('ref')               # get page name
             plot_empty = True                               # check if any data is plotted
             
             if page_name is None: # ignore 'empty' audio_holders
@@ -89,7 +89,7 @@
             # sort alphabetically
             data = []
             for elem in audioelements: # from http://effbot.org/zone/element-sort.htm
-                key = elem.get("id")
+                key = elem.get("ref")
                 data.append((key, elem))
             data.sort()
             
@@ -106,7 +106,7 @@
             for tuple in data:
                 audioelement = tuple[1]
                 if audioelement is not None: # Check it exists
-                    audio_id = str(audioelement.get('id'))
+                    audio_id = str(audioelement.get('ref'))
                     
                     # break if no initial position or move events registered
                     initial_position_temp = audioelement.find("./metric/metricresult/[@name='elementInitialPosition']")