arxivgpt kim
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,55 +1,61 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
questions = [
|
5 |
"1. λΉμ μ μ’μνλ μμ 무μμΈκ°μ?",
|
6 |
"2. μ£Όλ§μ κ°μ₯ νκ³ μΆμ νλμ?",
|
7 |
-
"3.
|
8 |
-
"4.
|
9 |
-
"5.
|
10 |
-
"6.
|
11 |
]
|
12 |
|
13 |
options = [
|
14 |
["λΉ¨κ°", "νλ", "λ
Ήμ"],
|
15 |
-
["μ°μ±
", "λ
μ", "μν
|
|
|
16 |
["νμ", "μ€μ", "μμ"],
|
17 |
-
["
|
18 |
-
["μμ€", "
|
19 |
-
["μ°", "λ°λ€", "λμ"]
|
20 |
]
|
21 |
|
22 |
scores = [
|
23 |
[1, 2, 3],
|
24 |
-
[3, 2, 1],
|
25 |
[2, 3, 1],
|
26 |
-
[
|
27 |
-
[3, 2
|
28 |
-
[2,
|
|
|
29 |
]
|
30 |
|
31 |
# μ μ κ³μ° ν¨μ
|
32 |
def calculate_score(answers):
|
33 |
total_score = sum([scores[i][options[i].index(ans)] for i, ans in enumerate(answers)])
|
34 |
-
return f"
|
35 |
-
|
36 |
-
#
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# λ¬Έμ , μ νμ§, μ μ μ€μ
|
4 |
questions = [
|
5 |
"1. λΉμ μ μ’μνλ μμ 무μμΈκ°μ?",
|
6 |
"2. μ£Όλ§μ κ°μ₯ νκ³ μΆμ νλμ?",
|
7 |
+
"3. μ νΈνλ μ¬νμ§ μ νμ?",
|
8 |
+
"4. μ’μνλ μμμ 무μμΈκ°μ?",
|
9 |
+
"5. μ·¨λ―Έ μνλ‘ λ μ νΈνλ κ²μ?",
|
10 |
+
"6. μ½κΈ° μ’μνλ μ±
μ μ₯λ₯΄λ?"
|
11 |
]
|
12 |
|
13 |
options = [
|
14 |
["λΉ¨κ°", "νλ", "λ
Ήμ"],
|
15 |
+
["μ°μ±
", "λ
μ", "μν κ΄λ"],
|
16 |
+
["μ°", "λ°λ€", "λμ"],
|
17 |
["νμ", "μ€μ", "μμ"],
|
18 |
+
["μ΄λ", "μ리", "κ·Έλ¦Ό 그리기"],
|
19 |
+
["μμ€", "κ³Όν", "μμ¬"]
|
|
|
20 |
]
|
21 |
|
22 |
scores = [
|
23 |
[1, 2, 3],
|
|
|
24 |
[2, 3, 1],
|
25 |
+
[3, 1, 2],
|
26 |
+
[1, 3, 2],
|
27 |
+
[2, 1, 3],
|
28 |
+
[3, 2, 1]
|
29 |
]
|
30 |
|
31 |
# μ μ κ³μ° ν¨μ
|
32 |
def calculate_score(answers):
|
33 |
total_score = sum([scores[i][options[i].index(ans)] for i, ans in enumerate(answers)])
|
34 |
+
return f"μ΄ μ μλ {total_score}μ μ
λλ€."
|
35 |
+
|
36 |
+
# μΈν°νμ΄μ€ μμ±
|
37 |
+
def create_interface(question_idx):
|
38 |
+
with gr.Blocks() as demo:
|
39 |
+
with gr.Row():
|
40 |
+
gr.Markdown(questions[question_idx])
|
41 |
+
answer1 = gr.Radio(options[question_idx], label="μ ν")
|
42 |
+
|
43 |
+
with gr.Row():
|
44 |
+
gr.Markdown(questions[question_idx + 1])
|
45 |
+
answer2 = gr.Radio(options[question_idx + 1], label="μ ν")
|
46 |
+
|
47 |
+
if question_idx + 2 < len(questions):
|
48 |
+
btn_next = gr.Button("λ€μ")
|
49 |
+
btn_next.click(create_interface, inputs=[], outputs=[], _js="()=>{window.location.hash='page" + str((question_idx//2)+2) + "';}")
|
50 |
+
|
51 |
+
if question_idx + 2 >= len(questions):
|
52 |
+
btn_submit = gr.Button("μ μΆ")
|
53 |
+
result = gr.Textbox(label="μ΅μ’
κ²°κ³Ό")
|
54 |
+
btn_submit.click(calculate_score, inputs=[answer1, answer2], outputs=result)
|
55 |
+
|
56 |
+
return demo
|
57 |
+
|
58 |
+
# κ° νμ΄μ§λ³λ‘ μΈν°νμ΄μ€ μμ± λ° λΌμ°ν
|
59 |
+
for i in range(0, len(questions), 2):
|
60 |
+
demo = create_interface(i)
|
61 |
+
demo.launch(share=True, server_name="0.0.0.0", server_port=7860 + (i//2))
|