saattrupdan commited on
Commit
fe414ee
1 Parent(s): 1410875

feat: Add "incorrect answer" button

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -59,6 +59,7 @@ def main():
59
  with gr.Column():
60
  correct_btn = gr.Button(value="Correct")
61
  incorrect_btn = gr.Button(value="Incorrect")
 
62
  save_results_btn = gr.Button(value="Save results")
63
 
64
  correct_btn.click(
@@ -71,6 +72,11 @@ def main():
71
  inputs=[idx_box, question_box, answer_box],
72
  outputs=[idx_box, question_box, answer_box],
73
  )
 
 
 
 
 
74
  save_results_btn.click(fn=save_results)
75
 
76
  auth = [
@@ -145,5 +151,32 @@ def assign_incorrect(
145
  )
146
 
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  if __name__ == "__main__":
149
  main()
 
59
  with gr.Column():
60
  correct_btn = gr.Button(value="Correct")
61
  incorrect_btn = gr.Button(value="Incorrect")
62
+ incorrect_answer_btn = gr.Button(value="Incorrect Answer")
63
  save_results_btn = gr.Button(value="Save results")
64
 
65
  correct_btn.click(
 
72
  inputs=[idx_box, question_box, answer_box],
73
  outputs=[idx_box, question_box, answer_box],
74
  )
75
+ incorrect_answer_btn.click(
76
+ fn=partial(assign_incorrect_answer, itr=itr),
77
+ inputs=[idx_box, question_box, answer_box],
78
+ outputs=[idx_box, question_box, answer_box],
79
+ )
80
  save_results_btn.click(fn=save_results)
81
 
82
  auth = [
 
151
  )
152
 
153
 
154
+ def assign_incorrect_answer(
155
+ idx: str, question: str, answer: str, itr: Generator
156
+ ) -> tuple[gr.Markdown, gr.Markdown, gr.Markdown]:
157
+ """Assign the answer as incorrect.
158
+
159
+ Args:
160
+ idx:
161
+ The index of the sample to be assigned as incorrect.
162
+ question:
163
+ The question to be assigned as incorrect.
164
+ answer:
165
+ The answer to be assigned as incorrect.
166
+ itr:
167
+ The iterator over non-validated samples.
168
+
169
+ Returns:
170
+ The updated textboxes.
171
+ """
172
+ gr.Info(message="Assigned sample answer as incorrect")
173
+ logger.info(f"Assigned sample answer as incorrect: {answer}")
174
+ df.iloc[int(idx)].validation = "incorrect-answer"
175
+ idx, question, answer = next(itr)
176
+ return (
177
+ gr.Markdown(value=idx), gr.Markdown(value=question), gr.Markdown(value=answer)
178
+ )
179
+
180
+
181
  if __name__ == "__main__":
182
  main()