Mercurial > hg > webaudioevaluationtool
comparison scripts/comment_parser.py @ 880:24d0d3111c00
Scripts: added 'confidence interval plot' (rigorous checking needed) and minor fixes to other scripts.
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Thu, 25 Jun 2015 17:14:33 +0100 |
parents | 302926cdf3c4 |
children | cd20f076f6a3 |
comparison
equal
deleted
inserted
replaced
879:8ab5f8969856 | 880:24d0d3111c00 |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
2 | 3 |
3 import xml.etree.ElementTree as ET | 4 import xml.etree.ElementTree as ET |
4 import os | 5 import os |
5 import csv | 6 import csv |
6 | 7 |
20 # create folder [page_name] if not yet created | 21 # create folder [page_name] if not yet created |
21 if not os.path.exists(page_name): | 22 if not os.path.exists(page_name): |
22 os.makedirs(page_name) | 23 os.makedirs(page_name) |
23 | 24 |
24 # for page [page_name], print comments related to fragment [id] | 25 # for page [page_name], print comments related to fragment [id] |
25 for audioelement in root.findall("*/[@id='"+page_name+"']/audioelement"): | 26 for audioelement in root.findall("*/[@id='"+page_name+"']/audioelement"): #TODO in audioholder.findall(...) |
26 if audioelement is not None: # Check it exists | 27 if audioelement is not None: # Check it exists |
27 audio_id = str(audioelement.get('id')) | 28 audio_id = str(audioelement.get('id')) |
28 | 29 |
29 | 30 |
30 csv_name = page_name+'/'+page_name+'-comments-'+audio_id+'.csv' | 31 csv_name = page_name+'/'+page_name+'-comments-'+audio_id+'.csv' |
42 + "']/comment/response").text | 43 + "']/comment/response").text |
43 if commentstr is None: | 44 if commentstr is None: |
44 writer.writerow(['']) | 45 writer.writerow(['']) |
45 else: | 46 else: |
46 # anonymous comments: | 47 # anonymous comments: |
47 writer.writerow([commentstr]) | 48 writer.writerow([commentstr.encode("utf-8")]) |
48 # comments with (file) name: | 49 # comments with (file) name: |
49 #writer.writerow([file[:-4]] + [commentstr]) | 50 #writer.writerow([file[:-4]] + [commentstr.encode("utf-8")]) |
50 | 51 |
51 #TODO Replace 'new line' in comment with something else? | 52 #TODO Replace 'new line' in comment with something else? |
52 | 53 |
53 # PRO TIP: Change from csv to txt by running this in bash: | 54 # PRO TIP: Change from csv to txt by running this in bash: |
54 # $ cd folder_where_csvs_are/ | 55 # $ cd folder_where_csvs_are/ |