-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.py
83 lines (64 loc) · 2.25 KB
/
results.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
import pickle
import numpy as np
import torch
import argparse
import os
import logging
import sys
def load_data(data_dir):
with open(data_dir, 'rb') as f:
results = pickle.load(f)
return results
class TextResult(object):
def __init__(self,
context,
real_question,
posterior_question,
prior_question,
real_answer,
posterior_answer,
prior_answer):
self.context = context
self.real_question = real_question
self.posterior_question = posterior_question
self.prior_question = prior_question
self.real_answer = real_answer
self.posterior_answer = posterior_answer
self.prior_answer = prior_answer
def main():
args = setup()
results = load_data(args.results_file)
for index in args.indexes:
result = results[index]
print("Context :")
print(result.context + "\n")
print("real Question :")
print(result.real_question + "\n")
print("real Answer :")
print(result.real_answer + "\n")
print("posterior Question :")
print(result.posterior_question + "\n")
print("posterior Answer :")
print(result.posterior_answer + "\n")
print("prior Question :")
print(result.prior_question + "\n")
print("prior Answer :\n")
print(result.prior_answer + "\n")
def setup():
parser = argparse.ArgumentParser(
description='Train QA model.'
)
# system
parser.add_argument('--results_file', default="../ex/vae_reverse_true_feed/results.pkl",
help='path to saved results.')
parser.add_argument('--indexes', default=[22],
help='path to saved results.')
parser.add_argument('--what_to_gen', default='qa',
help='qa')
# model
parser.add_argument("--bert_model", default='bert-base-uncased', type=str,
help="Bert pre-trained model selected in the list: bert-base-uncased, bert-large-uncased")
args = parser.parse_args()
return args
if __name__ == '__main__':
main()