JRQi commited on
Commit
6335809
1 Parent(s): 08a437b

Update game1.py

Browse files
Files changed (1) hide show
  1. game1.py +50 -50
game1.py CHANGED
@@ -24,18 +24,18 @@ def read1(lang):
24
  while len(tokens) <= min_len or '\\' in text['text'] or '//' in text['text']:
25
  index_selected = random.randint(0,len(content)/2-1)
26
  text = eval(content[int(index_selected*2)])
27
- # res_tmp = [(i, 0) for i in text['text'].split(' ')]
28
- # res = {"original": text['text'], "interpretation": res_tmp}
29
- # res_empty = {"original": "", "interpretation": []}
30
-
31
- res = []
32
- res.append(("P", "+"))
33
- res.append(("/", None))
34
- res.append(("N", "-"))
35
- res.append(("Review:", None))
36
- for i in text['text'].split(' '):
37
- res.append((i, None))
38
- res_empty = None
39
  # checkbox_update = gr.CheckboxGroup.update(choices=tokens, value=None)
40
 
41
  return res, lang, index_selected, res_empty, 0, 0, []
@@ -62,7 +62,7 @@ def read1_written(lang):
62
  # print(res)
63
  return text['text']
64
 
65
- def func1(lang_selected, num_selected, human_predict, num1, num2, h1):
66
  chatbot = []
67
  # num1: Human score; num2: AI score
68
  if lang_selected in ['en']:
@@ -131,17 +131,17 @@ def func1(lang_selected, num_selected, human_predict, num1, num2, h1):
131
  # result[label] = out['score']
132
 
133
  user_select = "You focused on "
134
- flag_select = False
135
- for i in range(len(h1)):
136
- if h1[i][1] != None and h1[i][0] not in ["P", "N"]:
137
- flag_select = True
138
- user_select += "'" + h1[i][0] + "'"
139
- if i == len(h1) - 1:
140
- user_select += ". "
141
- else:
142
- user_select += ", "
143
- if not flag_select:
144
- user_select += "nothing. Interesting! "
145
  user_select += "Wanna see how the AI made the guess? Click here. ⬅️"
146
  if lang_selected in ['en']:
147
  if ai_predict == golden_label:
@@ -253,32 +253,32 @@ def interpre1(lang_selected, num_selected):
253
 
254
  print(interpretation)
255
 
256
- # interpretation = {"original": text['text'], "interpretation": interpretation}
257
- pos = []
258
- neg = []
259
- res = []
260
- for i in interpretation:
261
- if i[1] > 0:
262
- pos.append(i[1])
263
- elif i[1] < 0:
264
- neg.append(i[1])
265
- else:
266
- continue
267
- median_pos = np.median(pos)
268
- median_neg = np.median(neg)
269
-
270
-
271
- res.append(("P", "+"))
272
- res.append(("/", None))
273
- res.append(("N", "-"))
274
- res.append(("Review:", None))
275
- for i in interpretation:
276
- if i[1] > median_pos:
277
- res.append((i[0], "+"))
278
- elif i[1] < median_neg:
279
- res.append((i[0], "-"))
280
- else:
281
- res.append((i[0], None))
282
  return res
283
 
284
  def change_lang(choice):
 
24
  while len(tokens) <= min_len or '\\' in text['text'] or '//' in text['text']:
25
  index_selected = random.randint(0,len(content)/2-1)
26
  text = eval(content[int(index_selected*2)])
27
+ res_tmp = [(i, 0) for i in tokens]
28
+ res = {"original": text['text'], "interpretation": res_tmp}
29
+ res_empty = {"original": "", "interpretation": []}
30
+
31
+ # res = []
32
+ # res.append(("P", "+"))
33
+ # res.append(("/", None))
34
+ # res.append(("N", "-"))
35
+ # res.append(("Review:", None))
36
+ # for i in text['text'].split(' '):
37
+ # res.append((i, None))
38
+ # res_empty = None
39
  # checkbox_update = gr.CheckboxGroup.update(choices=tokens, value=None)
40
 
41
  return res, lang, index_selected, res_empty, 0, 0, []
 
62
  # print(res)
63
  return text['text']
64
 
65
+ def func1(lang_selected, num_selected, human_predict, num1, num2, user_marks):
66
  chatbot = []
67
  # num1: Human score; num2: AI score
68
  if lang_selected in ['en']:
 
131
  # result[label] = out['score']
132
 
133
  user_select = "You focused on "
134
+ # flag_select = False
135
+ # for i in range(len(user_marks)):
136
+ # if user_marks[i][1] != None and h1[i][0] not in ["P", "N"]:
137
+ # flag_select = True
138
+ # user_select += "'" + h1[i][0] + "'"
139
+ # if i == len(h1) - 1:
140
+ # user_select += ". "
141
+ # else:
142
+ # user_select += ", "
143
+ # if not flag_select:
144
+ # user_select += "nothing. Interesting! "
145
  user_select += "Wanna see how the AI made the guess? Click here. ⬅️"
146
  if lang_selected in ['en']:
147
  if ai_predict == golden_label:
 
253
 
254
  print(interpretation)
255
 
256
+ res = {"original": text['text'], "interpretation": interpretation}
257
+ # pos = []
258
+ # neg = []
259
+ # res = []
260
+ # for i in interpretation:
261
+ # if i[1] > 0:
262
+ # pos.append(i[1])
263
+ # elif i[1] < 0:
264
+ # neg.append(i[1])
265
+ # else:
266
+ # continue
267
+ # median_pos = np.median(pos)
268
+ # median_neg = np.median(neg)
269
+
270
+
271
+ # res.append(("P", "+"))
272
+ # res.append(("/", None))
273
+ # res.append(("N", "-"))
274
+ # res.append(("Review:", None))
275
+ # for i in interpretation:
276
+ # if i[1] > median_pos:
277
+ # res.append((i[0], "+"))
278
+ # elif i[1] < median_neg:
279
+ # res.append((i[0], "-"))
280
+ # else:
281
+ # res.append((i[0], None))
282
  return res
283
 
284
  def change_lang(choice):