-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tester.py
87 lines (78 loc) · 2.89 KB
/
Tester.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#Karuta Memorizer Helper
import random
from Poem import Poem
from Poem import emptyCard
X_CHOICES = 4
class Tester:
def __init__(self,poems):
self.poems = poems
self.correct = [0 for i in poems]
self.tried = [0 for i in poems]
def testFull(self,num = 1):
numCorrect = 0
for i in range(num):
if self.testPoem(int(len(self.poems)*random.random())+1):
numCorrect = numCorrect + 1
print 'You got '+str(100*numCorrect/num)+'% correct.'
def testPoem(self,poem):
index = poem-1
print self.poems[index].rverse1
notIt = self.poems[:index]+self.poems[index+1:]
random.shuffle(notIt)
notIt = notIt[:(X_CHOICES - 1)]
randomVerses = [self.poems[index].card()] + [i.card() for i in notIt]
random.shuffle(randomVerses)
for i in range(X_CHOICES):
print (str(i+1)+':\n'+randomVerses[i])
guess = input()-1
if randomVerses[guess] == self.poems[index].card():
print 'Correct!'
return True
else:
print ('Wrong! The answer was:\n'+self.poems[index].card())
raw_input()
return False
## def testPoems(self,poem):
## index = poem-1
## print self.poems[index].rverse1
## notIt = self.poems[:index]+self.poems[index+1:]
## random.shuffle(notIt)
## notIt = notIt[:13]
## cards = notIt + self.poems[index]
## random.shuffle(cards)
## emptyCard = emptyCard()
## row1 = concat([cards[0],cards[12],emptyCard,emptyCard,emptyCard,cards[13],cards[1]])
## row2 = concat([cards[2],cards[3],emptyCard,emptyCard,emptyCard,cards[4],cards[5]])
## row3 = concat([cards[6],cards[7],cards[8],emptyCard,cards[9],cards[10],cards[11]])
## print row1
## print row2
## print row3
def testK(self):
index = int(len(self.poems)*random.random())
print self.poems[index].rverse1
guess = input("What's the kimariji? -> ")
if guess == self.poems[index].kimariji[:-1]:
print 'Correct!'
else:
print 'Wrong! The answer was: '+self.poems[index].kimariji
self.testPoem(index+1)
def info(self,num):
p = self.poems[num-1]
print p.rverse1
print p.rverse2
print '\n'
print p.jverse1.decode('utf-8')
print p.jverse2.decode('utf-8')
print '\n'
print p.verse1
print p.verse2
print '\n'
print p.author
def search(self,unique):
for i in self.poems:
if i.kimariji[:-1] == unique:
return i.number
allPoems = [Poem(i+1) for i in range(100)]
learned = [100,13,15,17,18,2,21,22,23,28,32,33,35,37,40,42,46,47,48,51,57,59,6,61,62,63,65,66,67,70,71,74,75,77,81,83,85,87,9,91,93,96,98,99]
lp = [allPoems[i-1] for i in learned]
t = Tester(allPoems)