Skip to content
Browse files

added codey and alternate processingcsv.py file

alternate processing file added that has a different way of evaluating
data and corresponding codey.csv needed for the processingcsv.py
  • Loading branch information...
1 parent 3eec548 commit 6b4e1a1156f140c411ef978dc61a78c0696a8a1d ctmdev committed Nov 30, 2012
Showing with 231 additions and 11 deletions.
  1. +45 −0 src/codey.csv
  2. +51 −5 src/csvProcessShahin.py
  3. +40 −6 src/csvProcessShahin.py~
  4. +95 −0 src/processingcsv.py
View
45 src/codey.csv
@@ -0,0 +1,45 @@
+1,6
+2,3
+3,1
+4,8
+5,1
+6,3
+7,9
+8,5
+9,6
+10,5
+11,4
+12,2
+13,1
+14,7
+15,4
+16,2
+17,9
+18,8
+19,4
+20,6
+21,9
+22,5
+23,2
+24,5
+25,7
+26,4
+27,8
+28,2
+29,5
+30,7
+31,3
+32,4
+33,8
+34,1
+35,7
+36,7
+37,6
+38,9
+39,8
+40,1
+41,2
+42,3
+43,6
+44,3
+45,9
View
56 src/csvProcessShahin.py
@@ -19,16 +19,62 @@ def main():
print coldict
#calculate the number of correct answers
- numcorr = coldict['key_resp.corr']
- sumcorr = sum([map(int, i) for i in numcorr])
+ corrResp = coldict['key_resp.corr']
+ sumcorr = sum([map(int, i) for i in corrResp])
print 'number of correct responses: ' + str(sumcorr)
- #calculate the frequency of responses
+ #calculate the frequency of BA, WA responses
d = defaultdict(int)
for ans in coldict['key_resp.keys']:
d[ans] += 1
- print 'number times answered BA: ' + str(d['1'])
- print 'number times answered WA: ' + str(d['2'])
+
+ #gets the number of BA, WA responses
+ numBA = d['1']
+ numWA = d['2']
+
+ #find the number of BAs, WAs correct
+ corrKey = coldict['correct']
+ keyResp = coldict['key_resp.keys']
+ baCorr, baErr, waCorr, waErr, noneErr, noiseErr = 0, 0, 0, 0, 0, 0
+ for i in arange(0,len(coldict[0])):
+ if corrKey(i) == keyResp(i):
+ if corrKey(i) == 1:
+ baCorr += 1
+ if corrKey(i) == 2:
+ waCorr += 1
+ else #must do a fix for if the response is 'None'
+ if corrKey(i) == 1:
+ baErr += 1
+ if corrKey(i) == 2:
+ waErr += 1
+
+ if keyResp(i) == 'None':
+ noneErr += 1
+ if keyResp(i) == 3:
+ noiseErr += 1
+
+ with open codey.csv as codeycsv:
+ codeyfile = array([row.strip().split(',') for row in codeycsv])
+ codey = a[0:,1] #take codey column instead of index column
+
+ #baCorr (number of BAs correct)
+ #waCorr (number of WAs correct)
+
+ #test on the total number of correct answers
+ if baCorr + waCorr == sumcorr:
+ print 'total correct test: passed'
+ else
+ print 'total correct test: failed'
+
+ #test on number of error responses
+ if sumcorr + noneErr + noiseErr == len(corrKey):
+ print 'total error test: passed'
+ else
+ print 'total error test: failed'
+
+
+ print 'number times answered BA: ' + str(numBA)
+ print 'number times answered WA: ' + str(numWA)
if __name__ == '__main__':
main()
View
46 src/csvProcessShahin.py~
@@ -19,16 +19,50 @@ def main():
print coldict
#calculate the number of correct answers
- numcorr = coldict['enterResp.corr']
- sumcorr = sum([map(int, i) for i in numcorr])
+ corrResp = coldict['key_resp.corr']
+ sumcorr = sum([map(int, i) for i in corrResp])
print 'number of correct responses: ' + str(sumcorr)
- #calculate the frequency of responses
+ #calculate the frequency of BA, WA responses
d = defaultdict(int)
- for ans in coldict['enterResp.keys']:
+ for ans in coldict['key_resp.keys']:
d[ans] += 1
- print 'number times answered BA: ' + str(d['1'])
- print 'number times answered WA: ' + str(d['2'])
+
+ #gets the number of BA, WA responses
+ numBA = d['1']
+ numWA = d['2']
+
+ #find the number of BAs, WAs correct
+ corrKey = coldict['correct']
+ keyResp = coldict['key_resp.keys']
+ baCorr = 0
+ baErr = 0
+ waCorr = 0
+ waErr = 0
+ for i in arange(0,len(coldict[0])):
+ if corrKey(i) == keyResp(i):
+ if corrKey(i) == 1:
+ baCorr += 1
+ if corrKey(i) == 2:
+ waCorr += 1
+ else
+ if corrKey(i) == 1:
+ baErr += 1
+ if corrKey(i) == 2:
+ waErr += 1
+
+ #baCorr (number of BAs correct)
+ #waCorr (number of WAs correct)
+
+ #test on the total number of correct answers
+ if baCorr + waCorr == sumcorr:
+ print 'total correct test: passed'
+ else
+ print 'total correct test: failed'
+
+
+ print 'number times answered BA: ' + str(numBA)
+ print 'number times answered WA: ' + str(numWA)
if __name__ == '__main__':
main()
View
95 src/processingcsv.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+
+import sys
+import csv
+import pprint
+from numpy import arange, array, sum
+from collections import defaultdict
+
+def main():
+ #csv filename to evaluate => first argument in command prompt
+ filename = '../data/' + sys.argv[1]
+
+ with open (filename) as csvfile:
+ a = array([row.strip().split(',') for row in csvfile])
+ lengthRow = len(a[0])
+ coldict = dict((a[0,col],a[1:,col]) for col in arange(0,lengthRow-1))
+ ###check the length issue
+
+ with open ('codey.csv') as codeycsv:
+ codeyfile = array([row.strip().split(',') for row in codeycsv])
+ codey = codeyfile[0:,1] #take codey column instead of index column
+
+ #instantiate important data columns
+ isCorrect = coldict['key_resp.corr']
+ keyResp = coldict['key_resp.keys']
+
+ #create list of data tuples for each trial
+ trials = [None]*len(keyResp)
+ for i in arange(0,len(keyResp)):
+ trials[i] = (codey[i],isCorrect[i],keyResp[i])
+
+ #evaluate trial tuples
+ cod1, cod2, cod3, cod4, cod5, cod6, cod7, cod8, cod9 = 0,0,0,0,0,0,0,0,0
+ for dt in trials:
+ cod1 = cod1 + corrCod1(dt)
+ cod2 = cod2 + corrCod2(dt)
+ cod3 = cod3 + corrCod3(dt)
+ cod4 = cod4 + corrCod4(dt)
+ cod5 = cod5 + corrCod5(dt)
+ cod6 = cod6 + corrCod6(dt)
+ cod7 = cod7 + corrCod7(dt)
+ cod8 = cod8 + corrCod8(dt)
+ cod9 = cod9 + corrCod9(dt)
+
+ baTot = cod1 + cod2 + cod3 + cod4 + cod5 + cod6
+ waTot = cod7 + cod8 + cod9
+ synTot = cod1 + cod4 + cod7
+ maleTot = cod3 + cod6 + cod9
+ femaleTot = cod2 + cod5 + cod8
+ bawaTot = cod4 + cod5 + cod6
+ nosynTot = cod5 + cod6
+ bawaMaleTot = cod6
+ bawaFemaleTot = cod5
+
+ print 'Ba Correct: ' + str(baTot)
+ print 'Wa Correct: ' + str(waTot)
+ print 'Synthetic Correct: ' + str(synTot)
+ print 'Male Correct: ' + str(maleTot)
+ print 'Female Correct: ' + str(femaleTot)
+ print 'BaWa Correct: ' + str(bawaTot)
+ print 'Non-Synthetic Correct: ' + str(nosynTot)
+ print 'BaWa Male Correct: ' + str(bawaMaleTot)
+ print 'BaWa Female Correct: ' + str(bawaFemaleTot)
+
+#functions to return 1 if codey type value is true
+def corrCod1(datatuple):
+ return 1 if datatuple[0] == '1' and datatuple[1] == '1' else 0
+
+def corrCod2(datatuple):
+ return 1 if datatuple[0] == '2' and datatuple[1] == '1' else 0
+
+def corrCod3(datatuple):
+ return 1 if datatuple[0] == '3' and datatuple[1] == '1' else 0
+
+def corrCod4(datatuple):
+ return 1 if datatuple[0] == '4' and datatuple[1] == '1' else 0
+
+def corrCod5(datatuple):
+ return 1 if datatuple[0] == '5' and datatuple[1] == '1' else 0
+
+def corrCod6(datatuple):
+ return 1 if datatuple[0] == '6' and datatuple[1] == '1' else 0
+
+def corrCod7(datatuple):
+ return 1 if datatuple[0] == '7' and datatuple[1] == '1' else 0
+
+def corrCod8(datatuple):
+ return 1 if datatuple[0] == '8' and datatuple[1] == '1' else 0
+
+def corrCod9(datatuple):
+ return 1 if datatuple[0] == '9' and datatuple[1] == '1' else 0
+
+if __name__ == '__main__':
+ main()
+

0 comments on commit 6b4e1a1

Please sign in to comment.
Something went wrong with that request. Please try again.