-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbas_export_mockup.py
253 lines (225 loc) · 8.92 KB
/
dbas_export_mockup.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/usr/bin/env python3
from flask import Flask, jsonify
from flask_cors import CORS
app = Flask(__name__)
CORS(app) # Set security headers for Web requests
@app.route('/export/doj/<int:discussion>')
def export_dummy_discussion(discussion):
"""
Return a json string with dbas export style data of an example discussion.
:param discussion: discussion ID
:return: json string
"""
nodes = []
inferences = []
undercuts = []
if discussion == 1:
# Nixon Diamond example discussion
nodes = [1, 2, 3]
inferences = [{'id': 1,
'premises': [2],
'is_supportive': True,
'conclusion': 1},
{'id': 2,
'premises': [3],
'is_supportive': False,
'conclusion': 1}]
elif discussion == 2:
# Extended Nixon Diamond example discussion
nodes = [1, 2, 3, 4, 5]
inferences = [{'id': 1,
'premises': [2],
'is_supportive': True,
'conclusion': 1},
{'id': 2,
'premises': [3],
'is_supportive': False,
'conclusion': 1},
{'id': 3,
'premises': [4],
'is_supportive': False,
'conclusion': 2}]
undercuts = [{'id': 4,
'premises': [5],
'conclusion': 2}]
elif discussion == 3:
# Town policy debate example discussion with 7 statements
nodes = [76, 77, 78, 79, 80, 81, 82]
inferences = [{'id': 65,
'premises': [77],
'is_supportive': True,
'conclusion': 76},
{'id': 66,
'premises': [78],
'is_supportive': False,
'conclusion': 76},
{'id': 67,
'premises': [79],
'is_supportive': False,
'conclusion': 76},
{'id': 68,
'premises': [80, 81],
'is_supportive': False,
'conclusion': 79}]
undercuts = [{'id': 69,
'premises': [82],
'conclusion': 65}]
elif discussion == 4:
# Simplified town policy debate example discussion (only rebut)
nodes = [76, 77, 78]
inferences = [{'id': 65,
'premises': [77],
'is_supportive': True,
'conclusion': 76},
{'id': 66,
'premises': [78],
'is_supportive': False,
'conclusion': 76}]
elif discussion == 5:
# Town policy debate example discussion with 6 statements
nodes = [76, 77, 78, 79, 80, 81]
inferences = [{'id': 65,
'premises': [77],
'is_supportive': True,
'conclusion': 76},
{'id': 66,
'premises': [78],
'is_supportive': False,
'conclusion': 76},
{'id': 67,
'premises': [79, 80],
'is_supportive': False,
'conclusion': 78}]
undercuts = [{'id': 68,
'premises': [81],
'conclusion': 65}]
elif discussion == 6:
# Simplified town policy debate example discussion (only undercut)
nodes = [76, 77, 82]
inferences = [{'id': 65,
'premises': [77],
'is_supportive': True,
'conclusion': 76}]
undercuts = [{'id': 69,
'premises': [82],
'conclusion': 65}]
elif discussion == 7:
# Simplified town policy debate example discussion (only undermine)
nodes = [76, 79, 80]
inferences = [{'id': 67,
'premises': [79],
'is_supportive': False,
'conclusion': 76},
{'id': 68,
'premises': [80],
'is_supportive': False,
'conclusion': 79}]
return jsonify({'nodes': nodes,
'inferences': inferences,
'undercuts': undercuts})
@app.route('/export/doj_user/<int:user>/<int:discussion>')
def export_dummy_useropinion(user, discussion):
"""
Return a json string with dbas export style data of an example discussion.
:param user: user ID
:param discussion: discussion ID
:return: json string
"""
marked_statements = []
marked_arguments = []
rejected_arguments = []
accepted_statements_via_click = []
rejected_statements_via_click = []
if discussion == 1:
# Nixon Diamond example discussion
if user == 1:
accepted_statements_via_click = [2]
rejected_statements_via_click = [3]
elif user == 2:
accepted_statements_via_click = [2, 3]
rejected_statements_via_click = []
elif user == 3:
accepted_statements_via_click = [1, 3]
rejected_statements_via_click = []
elif discussion == 2:
# Extended Nixon Diamond example discussion
if user == 1:
accepted_statements_via_click = [3, 4]
rejected_statements_via_click = [5]
if discussion == 3:
# Town policy debate example discussion
if user == 1:
accepted_statements_via_click = [76, 77, 80, 81]
rejected_statements_via_click = [78, 79, 82]
elif user == 2:
accepted_statements_via_click = [77, 78, 80, 81, 82]
rejected_statements_via_click = [76, 79]
elif user == 3:
accepted_statements_via_click = [77, 78, 80, 81, 82]
rejected_statements_via_click = []
elif discussion == 4:
# Simplified town policy debate example discussion (only rebut)
if user == 1:
accepted_statements_via_click = [76, 77]
rejected_statements_via_click = []
elif user == 2:
accepted_statements_via_click = [78]
rejected_statements_via_click = [76]
elif user == 3:
accepted_statements_via_click = [77]
rejected_statements_via_click = [78]
elif user == 4:
accepted_statements_via_click = [77, 78]
rejected_statements_via_click = []
elif user == 5:
accepted_statements_via_click = [76, 78]
rejected_statements_via_click = []
if discussion == 5:
# Town policy debate example discussion with 6 statements
if user == 1:
accepted_statements_via_click = [77]
rejected_statements_via_click = [78]
elif user == 2:
accepted_statements_via_click = [78]
rejected_statements_via_click = [77]
elif user == 3:
accepted_statements_via_click = [77, 78]
rejected_statements_via_click = []
elif user == 4:
accepted_statements_via_click = [77, 78, 79, 80, 81]
rejected_statements_via_click = []
if discussion == 6:
# Simplified town policy debate example discussion (only undercut)
if user == 1:
accepted_statements_via_click = [77]
rejected_statements_via_click = [82]
elif user == 2:
accepted_statements_via_click = [82]
rejected_statements_via_click = [77]
elif user == 3:
accepted_statements_via_click = [77, 82]
rejected_statements_via_click = []
elif user == 4:
accepted_statements_via_click = []
rejected_statements_via_click = [77, 82]
if discussion == 7:
# Simplified town policy debate example discussion (only undermine)
if user == 1:
accepted_statements_via_click = [79]
rejected_statements_via_click = [80]
elif user == 2:
accepted_statements_via_click = [80]
rejected_statements_via_click = [79]
elif user == 3:
accepted_statements_via_click = [79, 80]
rejected_statements_via_click = []
elif user == 4:
accepted_statements_via_click = []
rejected_statements_via_click = [79, 80]
return jsonify({'marked_statements': marked_statements,
'marked_arguments': marked_arguments,
'rejected_arguments': rejected_arguments,
'accepted_statements_via_click': accepted_statements_via_click,
'rejected_statements_via_click': rejected_statements_via_click})
if __name__ == '__main__':
app.run(threaded=True, port=4284)