Spaces:
Runtime error
Runtime error
Yoon-gu Hwang
commited on
Commit
•
97b3e3f
1
Parent(s):
21ef542
버그 수정
Browse files
app.py
CHANGED
@@ -30,7 +30,6 @@ def get_question_answer(pokemons_set):
|
|
30 |
chosen = random.choice(pokemons_set)
|
31 |
name = chosen['name'].replace("♀", "암컷").replace("♂", "수컷")
|
32 |
image_path = chosen['image_path']
|
33 |
-
answer.value = QUESTION_TEMPLATE['answer'].format(name=name)
|
34 |
img_url = f"https://huggingface.co/spaces/yoon-gu/pokemon/resolve/main/{image_path}"
|
35 |
q = QUESTION_TEMPLATE["question"].format(img_url=img_url)
|
36 |
a = QUESTION_TEMPLATE['answer'].format(name=name)
|
@@ -56,7 +55,6 @@ MD = """# 포켓몬 퀴즈
|
|
56 |
"""
|
57 |
|
58 |
with gr.Blocks() as demo:
|
59 |
-
answer = gr.State(value="")
|
60 |
with gr.Row():
|
61 |
with gr.Column():
|
62 |
markdown = gr.Markdown(MD.format(content=''))
|
@@ -95,7 +93,7 @@ with gr.Blocks() as demo:
|
|
95 |
if "퀴즈시작" == message.replace(" ", ""):
|
96 |
q, a = get_question_answer(pokemons_set)
|
97 |
bot_message = f"퀴즈를 시작합니다.\n{q}"
|
98 |
-
answer
|
99 |
info[user]['done'] = False
|
100 |
info[user]['score'] = 0
|
101 |
info[user]['count'] = 0
|
@@ -103,9 +101,9 @@ with gr.Blocks() as demo:
|
|
103 |
else:
|
104 |
bot_message = "퀴즈를 시작하고 싶으시면, **퀴즈 시작** 버튼을 누르세요."
|
105 |
else:
|
106 |
-
if answer
|
107 |
q, a = get_question_answer(pokemons_set)
|
108 |
-
answer
|
109 |
info[user]['score'] += 1
|
110 |
info[user]['count'] += 1
|
111 |
bot_message = f"🎉정답입니다! 다음 문제입니다.\n{q}\n- 현재 점수: {info[user]['score']}점\n- 소요 시간: {time.time() - info[user]['time']:4.3f}초"
|
@@ -116,11 +114,11 @@ with gr.Blocks() as demo:
|
|
116 |
elif "문제 넘어가기" == message:
|
117 |
info[user]['count'] += 1
|
118 |
q, a = get_question_answer(pokemons_set)
|
119 |
-
answer
|
120 |
bot_message = f"문제를 넘어갑니다. 다음문제입니다.\n{q}"
|
121 |
else:
|
122 |
hint1 = ""
|
123 |
-
for i, y in enumerate(answer
|
124 |
if i < len(message):
|
125 |
if message[i] == y:
|
126 |
hint1 += y
|
|
|
30 |
chosen = random.choice(pokemons_set)
|
31 |
name = chosen['name'].replace("♀", "암컷").replace("♂", "수컷")
|
32 |
image_path = chosen['image_path']
|
|
|
33 |
img_url = f"https://huggingface.co/spaces/yoon-gu/pokemon/resolve/main/{image_path}"
|
34 |
q = QUESTION_TEMPLATE["question"].format(img_url=img_url)
|
35 |
a = QUESTION_TEMPLATE['answer'].format(name=name)
|
|
|
55 |
"""
|
56 |
|
57 |
with gr.Blocks() as demo:
|
|
|
58 |
with gr.Row():
|
59 |
with gr.Column():
|
60 |
markdown = gr.Markdown(MD.format(content=''))
|
|
|
93 |
if "퀴즈시작" == message.replace(" ", ""):
|
94 |
q, a = get_question_answer(pokemons_set)
|
95 |
bot_message = f"퀴즈를 시작합니다.\n{q}"
|
96 |
+
info[user]['answer'] = a
|
97 |
info[user]['done'] = False
|
98 |
info[user]['score'] = 0
|
99 |
info[user]['count'] = 0
|
|
|
101 |
else:
|
102 |
bot_message = "퀴즈를 시작하고 싶으시면, **퀴즈 시작** 버튼을 누르세요."
|
103 |
else:
|
104 |
+
if info[user]['answer'] == message:
|
105 |
q, a = get_question_answer(pokemons_set)
|
106 |
+
info[user]['answer'] = a
|
107 |
info[user]['score'] += 1
|
108 |
info[user]['count'] += 1
|
109 |
bot_message = f"🎉정답입니다! 다음 문제입니다.\n{q}\n- 현재 점수: {info[user]['score']}점\n- 소요 시간: {time.time() - info[user]['time']:4.3f}초"
|
|
|
114 |
elif "문제 넘어가기" == message:
|
115 |
info[user]['count'] += 1
|
116 |
q, a = get_question_answer(pokemons_set)
|
117 |
+
info[user]['answer'] = a
|
118 |
bot_message = f"문제를 넘어갑니다. 다음문제입니다.\n{q}"
|
119 |
else:
|
120 |
hint1 = ""
|
121 |
+
for i, y in enumerate(info[user]['answer']):
|
122 |
if i < len(message):
|
123 |
if message[i] == y:
|
124 |
hint1 += y
|