|
import gradio as gr |
|
|
|
|
|
questions = [ |
|
"1. λΉμ μ μ’μνλ μμ 무μμΈκ°μ?", |
|
"2. μ£Όλ§μ κ°μ₯ νκ³ μΆμ νλμ?", |
|
"3. μ νΈνλ μμμ 무μμΈκ°μ?", |
|
"4. μ¬νμ κ°κ³ μΆμ λλΌλ μ΄λμΈκ°μ?", |
|
"5. μ’μνλ κ³μ μ 무μμΈκ°μ?", |
|
"6. μ½κ³ μΆμ μ±
μ μ₯λ₯΄λ?" |
|
] |
|
|
|
options = [ |
|
["λΉ¨κ°", "νλ", "μ΄λ‘"], |
|
["μ°μ±
", "λ
μ", "μν κ°μ"], |
|
["νμ", "μ€μ", "μμ"], |
|
["νκ΅", "μΌλ³Έ", "λ―Έκ΅"], |
|
["λ΄", "μ¬λ¦", "κ°μ", "겨μΈ"], |
|
["μμ€", "μκΈ°κ³λ°", "μμ¬"] |
|
] |
|
|
|
scores = [ |
|
[1, 2, 3], |
|
[2, 3, 4], |
|
[3, 4, 5], |
|
[4, 5, 6], |
|
[5, 6, 7, 8], |
|
[6, 7, 8] |
|
] |
|
|
|
def calculate_score(*answers): |
|
total_score = sum([scores[i][options[i].index(answer)] for i, answer in enumerate(answers)]) |
|
return f"μ΄μ : {total_score}" |
|
|
|
with gr.Blocks() as demo: |
|
with gr.Tab("ν΄μ¦ 1"): |
|
answer1 = gr.Radio(choices=options[0], label=questions[0]) |
|
answer2 = gr.Radio(choices=options[1], label=questions[1]) |
|
with gr.Tab("ν΄μ¦ 2"): |
|
answer3 = gr.Radio(choices=options[2], label=questions[2]) |
|
answer4 = gr.Radio(choices=options[3], label=questions[3]) |
|
with gr.Tab("ν΄μ¦ 3"): |
|
answer5 = gr.Radio(choices=options[4], label=questions[4]) |
|
answer6 = gr.Radio(choices=options[5], label=questions[5]) |
|
submit_btn = gr.Button("μ μΆ") |
|
result = gr.Textbox(label="κ²°κ³Ό") |
|
|
|
submit_btn.click( |
|
fn=calculate_score, |
|
inputs=[answer1, answer2, answer3, answer4, answer5, answer6], |
|
outputs=result |
|
) |
|
|
|
demo.launch() |
|
|