korav / app.py
arxivgpt kim
Update app.py
b1efa62 verified
raw
history blame
1.68 kB
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()