-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_fq_dataset.py
239 lines (210 loc) · 10.1 KB
/
test_fq_dataset.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
from logging.handlers import RotatingFileHandler
import unittest
import inspect
import application.summary.kg.dbpedia.DBpediaEN as dbpedia_en
import application.summary.kg.wikidata.WikidataEN as wikidata_en
import application.summary.txt.Cord19EN as cord19_en
import application.extraction.BertEQA as bert_en
import application.extraction.RobertaCovidEQA as roberta_covid_en
import application.extraction.RobertaEQA as roberta_en
import application.response.BertAnswererEN as response_en
import application.workflow as wf
import application.datasets.forwardquestions.fqdataset as dataset
#Summary
dbpediaEN = dbpedia_en.DBpediaEN()
dbpedia_lm_EN = dbpedia_en.DBpediaEN(rules=False)
wikidataEN = wikidata_en.WikidataEN()
wikidata_lm_EN = wikidata_en.WikidataEN(rules=False)
cord19EN = cord19_en.Cord19EN()
# Extraction
bertEQA = bert_en.BertEQA()
robertaCovidEQA = roberta_covid_en.RobertaCovidEQA()
robertaEQA = roberta_en.RobertaEQA()
# Response
bertRsp = response_en.BertAnswererEN()
class FQTest(unittest.TestCase):
def setUp(self):
print("############### Test:")
self.input_data = "application/datasets/forwardquestions/data/all_questions.json"
self.dataset = dataset.ForwardQuestionsDataset(input_file=self.input_data)
self.size = 1000
#self.size = 38479
self.out_folder = "results/"
def tearDown(self):
print("Test done!")
############################################################################
### Wikidata
############################################################################
#@unittest.skip
def test_fq_000(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidataEN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_001(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidata_lm_EN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_002(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = True
summary = [wikidataEN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_003(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = True
summary = [wikidata_lm_EN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_004(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidataEN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_005(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidata_lm_EN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_006(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = True
summary = [wikidataEN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_007(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = True
summary = [wikidata_lm_EN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
############################################################################
### DBpedia
############################################################################
#@unittest.skip
def test_fq_008(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [dbpediaEN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_009(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [dbpedia_lm_EN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_010(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [dbpediaEN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_011(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [dbpedia_lm_EN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
############################################################################
### Wikidata+DBpedia
############################################################################
#@unittest.skip
def test_fq_012(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidataEN,dbpediaEN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_013(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidata_lm_EN,dbpedia_lm_EN]
extraction = bertEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_014(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidataEN,dbpediaEN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
#@unittest.skip
def test_fq_015(self):
test_name = inspect.stack()[0][3]+"_"+str(self.size)+".json"
entities = False
summary = [wikidata_lm_EN,dbpedia_lm_EN]
extraction = robertaEQA
response = bertRsp
workflow = wf.Workflow(summary,extraction,response)
count = self.dataset.test(workflow,file_name=self.out_folder+test_name,limit=self.size,use_entities=entities,get_evidence=True,pool_size=1)
self.assertEqual(count, self.size)
if __name__ == '__main__':
import xmlrunner
unittest.main(
testRunner=xmlrunner.XMLTestRunner(output='test-reports'),
failfast=False,
buffer=False,
catchbreak=False)