comparison deep/amt/amt.py @ 401:86d5e583e278

Fixed class number bug
author humel
date Wed, 28 Apr 2010 01:25:52 -0400
parents 99905d9bc9dd
children 83413ac10913
comparison
equal deleted inserted replaced
400:8973abe35a9d 401:86d5e583e278
7 7
8 answer_labels = [ 'Answer.C'+str(i+1) for i in range(10) ] 8 answer_labels = [ 'Answer.C'+str(i+1) for i in range(10) ]
9 img_url = 'Input.image_url' 9 img_url = 'Input.image_url'
10 turks_per_batch = 3 10 turks_per_batch = 3
11 11
12
13 def setup_association():
14 answer_assoc = {}
15 for i in range(0,10):
16 answer_assoc[str(i)]=i
17 for i in range(10,36):
18 answer_assoc[chr(i+55)]=i
19 for i in range(36,62):
20 answer_assoc[chr(i+61)]=i
21 return answer_assoc
22
23 answer_assoc = setup_association()
12 24
13 def test_error(): 25 def test_error():
14 turks = [] 26 turks = []
15 reader = csv.DictReader(open(CVSFILE), delimiter=',') 27 reader = csv.DictReader(open(CVSFILE), delimiter=',')
16 entries = [ turk for turk in reader ] 28 entries = [ turk for turk in reader ]
41 f = open(PATH+file,'r') 53 f = open(PATH+file,'r')
42 labels = re.sub("\s+", "",f.readline()).strip()[1:-2].split('.') 54 labels = re.sub("\s+", "",f.readline()).strip()[1:-2].split('.')
43 f.close() 55 f.close()
44 test_error = 0 56 test_error = 0
45 for i in range(len(answer_labels)): 57 for i in range(len(answer_labels)):
46 try: 58 answer = entry[answer_labels[i]]
47 answer = int(entry[answer_labels[i]]) 59 if len(answer) != 0:
48 except: 60 try:
49 try : 61 if answer_assoc[answer] != int(labels[i]):
50 answer = ord(entry[answer_labels[i]]) 62 test_error+=1
51 except: 63 except:
52 test_error+=1 64 test_error+=1
53 continue 65 else:
54 if answer != int(labels[i]):
55 test_error+=1 66 test_error+=1
56 return test_error 67 return test_error
57 68
58 69
59 def parse_filename(string): 70 def parse_filename(string):