-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_util.py
More file actions
138 lines (112 loc) · 6.47 KB
/
test_util.py
File metadata and controls
138 lines (112 loc) · 6.47 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
from unittest import TestCase
from util import convert_and_caching_prob
from datasets.dataset import Problem
class Test(TestCase):
def test_convert_and_caching_prob(self):
case1 = {
"ID": "chal-1",
"Body": "Each pack of dvds costs 76 dollars. If there is a discount of 25 dollars on each pack",
"Question": "How much do you have to pay to buy each pack?",
"Equation": "( 76.0 - 25.0 )",
"Answer": 51.0,
"Type": "Subtraction"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case1['Body'], question=case1['Question'], answer=case1['Answer']), inplace=False)
self.assertEqual(passage, 'Each pack of dvds costs number0 dollars. If there is a discount of number1 dollars on each pack')
self.assertEqual(question, 'How much do you have to pay to buy each pack?')
self.assertEqual(cache, 'number0 = 76\nnumber1 = 25\n')
case2 = {
"ID": "chal-12",
"Body": "They decided to hold the party in their backyard. If they have 11 sets of tables and each set has 13 chairs",
"Question": "How many chairs do they have in the backyard?",
"Equation": "( 11.0 * 13.0 )",
"Answer": 143.0,
"Type": "Multiplication"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case2['Body'], question=case2['Question'], answer=case2['Answer']), inplace=False)
self.assertEqual(passage, 'They decided to hold the party in their backyard. If they have number0 sets of tables and each set has number1 chairs')
self.assertEqual(question, 'How many chairs do they have in the backyard?')
self.assertEqual(cache, 'number0 = 11\nnumber1 = 13\n')
case3 = {
"ID": "chal-13",
"Body": "In a school there are 458 more girls than boys. If there are 690 girls",
"Question": "How many pupils are there in that school?",
"Equation": "( ( 690.0 + 690.0 ) - 458.0 )",
"Answer": 926.0,
"Type": "Subtraction"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case3['Body'], question=case3['Question'], answer=case3['Answer']), inplace=False)
self.assertEqual(passage, "In a school there are number0 more girls than boys. If there are number1 girls")
self.assertEqual(question, "How many pupils are there in that school?")
self.assertEqual(cache, "number0 = 458\nnumber1 = 690\n")
case4 = {
"ID": "chal-126",
"Body": "Kelly has 22 nintendo games.",
"Question": "How many does she need to buy so that she will have 140 games left?",
"Equation": "( 140.0 - 22.0 )",
"Answer": 118.0,
"Type": "Subtraction"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case4['Body'], question=case4['Question'], answer=case4['Answer']), inplace=False)
self.assertEqual(passage, "Kelly has number0 nintendo games.")
self.assertEqual(question, "How many does she need to buy so that she will have number1 games left?")
self.assertEqual(cache, "number0 = 22\nnumber1 = 140\n")
def test_convert_and_caching_prob_inplace(self):
case1 = {
"ID": "chal-1",
"Body": "Each pack of dvds costs 76 dollars. If there is a discount of 25 dollars on each pack",
"Question": "How much do you have to pay to buy each pack?",
"Equation": "( 76.0 - 25.0 )",
"Answer": 51.0,
"Type": "Subtraction"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case1['Body'], question=case1['Question'], answer=case1['Answer']), inplace=True)
self.assertEqual(passage,
'Each pack of dvds costs 76(number0) dollars. If there is a discount of 25(number1) dollars on each pack')
self.assertEqual(question, 'How much do you have to pay to buy each pack?')
self.assertEqual(cache, 'number0 = 76\nnumber1 = 25\n')
case2 = {
"ID": "chal-12",
"Body": "They decided to hold the party in their backyard. If they have 11 sets of tables and each set has 13 chairs",
"Question": "How many chairs do they have in the backyard?",
"Equation": "( 11.0 * 13.0 )",
"Answer": 143.0,
"Type": "Multiplication"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case2['Body'], question=case2['Question'], answer=case2['Answer']), inplace=True)
self.assertEqual(passage,
'They decided to hold the party in their backyard. If they have 11(number0) sets of tables and each set has 13(number1) chairs')
self.assertEqual(question, 'How many chairs do they have in the backyard?')
self.assertEqual(cache, 'number0 = 11\nnumber1 = 13\n')
case3 = {
"ID": "chal-13",
"Body": "In a school there are 458 more girls than boys. If there are 690 girls",
"Question": "How many pupils are there in that school?",
"Equation": "( ( 690.0 + 690.0 ) - 458.0 )",
"Answer": 926.0,
"Type": "Subtraction"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case3['Body'], question=case3['Question'], answer=case3['Answer']), inplace=True)
self.assertEqual(passage, "In a school there are 458(number0) more girls than boys. If there are 690(number1) girls")
self.assertEqual(question, "How many pupils are there in that school?")
self.assertEqual(cache, "number0 = 458\nnumber1 = 690\n")
case4 = {
"ID": "chal-126",
"Body": "Kelly has 22 nintendo games.",
"Question": "How many does she need to buy so that she will have 140 games left?",
"Equation": "( 140.0 - 22.0 )",
"Answer": 118.0,
"Type": "Subtraction"
}
passage, question, cache = convert_and_caching_prob(
Problem(passage=case4['Body'], question=case4['Question'], answer=case4['Answer']), inplace=True)
self.assertEqual(passage, "Kelly has 22(number0) nintendo games.")
self.assertEqual(question, "How many does she need to buy so that she will have 140(number1) games left?")
self.assertEqual(cache, "number0 = 22\nnumber1 = 140\n")