-
Notifications
You must be signed in to change notification settings - Fork 4
/
genTestData.py
executable file
·56 lines (41 loc) · 1.88 KB
/
genTestData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
from random import choice
import sys
from hexadecimal_testdata.hexdata import genData as hexData
from englishword_testdata.gen_basic import genData as englishWordData
from englishpoems_testdata.gendata import genData as englishPoemData
from pseudoword_testdata.keyname_script import genData as pseudoWordData
"""
4 Fingerprint Types (TODO: what happened to 5th?)
2 Comparison Mechanisms
2 Error Rates
x 2 Outcomes (Match or Not-Match)
---
32 Test Cases
Run: ./genTestData.py <testerpairs> > testData.csv
"""
def farFingerprintsToCompare(genData) :
perfectMatch,almostMatch = genData()
noMatch,noMatch = genData()
return perfectMatch,choice([perfectMatch,noMatch])
def closeFingerprintsToCompare(genData):
perfectMatch,almostMatch = genData()
noMatch,noMatch = genData()
return perfectMatch,choice([perfectMatch,almostMatch])
def normalize(s):
return s.strip().replace('\n','<br>')
fingerprints = {'hex':hexData,'english word':englishWordData,'english poem':englishPoemData,'pseudo word':pseudoWordData}
comparisons = ['Business card','Phone']
errors = {'large mismatch':farFingerprintsToCompare,'small mismatch':closeFingerprintsToCompare}
outcomes = ['match','not match']
def genTestData(testerpairs):
print '#pair\tfingerprint\tcomparison\terror\tAlice\tBob\tjudgement'
for tid in range(testerpairs):
for mech in comparisons:
for errorDesc,errorFunc in errors.items():
for fingerprintDesc,fingerprintFunc in fingerprints.items():
for possibleOutcome in outcomes:
alicePrint,bobPrint = errorFunc(fingerprintFunc)
print '\t'.join([str(tid),fingerprintDesc,mech,errorDesc,normalize(alicePrint),normalize(bobPrint)])
if __name__ == '__main__':
genTestData(int(sys.argv[1]))