Spaces:
Runtime error
Runtime error
Commit ·
f86b6ce
1
Parent(s): 1659ccb
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
import text_gen as gen
|
| 4 |
|
| 5 |
|
| 6 |
-
NUM_QUESTIONS =
|
| 7 |
answers = {}
|
| 8 |
separator = '<[._.]>'
|
| 9 |
|
|
@@ -27,7 +27,14 @@ def get_answer(question, answer, options):
|
|
| 27 |
|
| 28 |
def set_score():
|
| 29 |
global answers
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
wrong_answers = {q:[gen.generate_text(
|
|
@@ -49,7 +56,8 @@ with gr.Blocks(theme='glass') as demo:
|
|
| 49 |
|
| 50 |
with gr.Column(scale=2):
|
| 51 |
|
| 52 |
-
gr.Markdown(f'## <p style="text-align: center;">
|
|
|
|
| 53 |
|
| 54 |
for ind, question in enumerate(list(questions.keys()), start=1):
|
| 55 |
letters = list('ABCD')
|
|
@@ -71,7 +79,4 @@ with gr.Blocks(theme='glass') as demo:
|
|
| 71 |
button.click(fn=set_score, outputs=score)
|
| 72 |
|
| 73 |
with gr.Column(scale=1):
|
| 74 |
-
pass
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
demo.launch()
|
|
|
|
| 3 |
import text_gen as gen
|
| 4 |
|
| 5 |
|
| 6 |
+
NUM_QUESTIONS = 10
|
| 7 |
answers = {}
|
| 8 |
separator = '<[._.]>'
|
| 9 |
|
|
|
|
| 27 |
|
| 28 |
def set_score():
|
| 29 |
global answers
|
| 30 |
+
global NUM_QUESTIONS
|
| 31 |
+
score = sum(answers.values())
|
| 32 |
+
start = '## <p style="text-align: center;">'
|
| 33 |
+
end = '</p>'
|
| 34 |
+
if score == 0: return f'{start}Not a single right answer. Are you doing this on purpose?{end}'
|
| 35 |
+
elif score <= NUM_QUESTIONS / 2 + 1: return f'{start}Only {score} right answers out of {NUM_QUESTIONS}. You ought to pay more attention.{end}'
|
| 36 |
+
elif score == NUM_QUESTIONS: return f'{start}Perfect score!{end}'
|
| 37 |
+
else: return f'{start}{score} right answers out of {NUM_QUESTIONS}. It\'s probably alright.{end}'
|
| 38 |
|
| 39 |
|
| 40 |
wrong_answers = {q:[gen.generate_text(
|
|
|
|
| 56 |
|
| 57 |
with gr.Column(scale=2):
|
| 58 |
|
| 59 |
+
gr.Markdown(f'## <p style="text-align: center;">IMITATION GAME</p>\n' +
|
| 60 |
+
f'### <p style="text-align: center;">Choose answers NOT given by an AI model.')
|
| 61 |
|
| 62 |
for ind, question in enumerate(list(questions.keys()), start=1):
|
| 63 |
letters = list('ABCD')
|
|
|
|
| 79 |
button.click(fn=set_score, outputs=score)
|
| 80 |
|
| 81 |
with gr.Column(scale=1):
|
| 82 |
+
pass
|
|
|
|
|
|
|
|
|