mbtitest / app.py
honey90's picture
Upload app.py with huggingface_hub
5c7dd2e verified
Raw History Blame Contribute Delete
26.2 kB
import gradio as gr
# MBTI ๊ด€๋ จ ๋ฐ์ดํ„ฐ
questions = [
{
"question": "1. ์ƒˆ๋กœ์šด ์‚ฌ๋žŒ๋“ค์„ ๋งŒ๋‚  ๋•Œ, ๋‹น์‹ ์€:",
"options": ["A. ๋จผ์ € ๋‹ค๊ฐ€๊ฐ€ ๋Œ€ํ™”๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ํŽธ์ด๋‹ค.", "B. ๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด ๋จผ์ € ๋‹ค๊ฐ€์™€ ์ฃผ๊ธธ ๊ธฐ๋‹ค๋ฆฌ๋Š” ํŽธ์ด๋‹ค."],
"scale": "EI", # E=A, I=B
},
{
"question": "2. ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ๋•Œ, ๋‹น์‹ ์€:",
"options": ["A. ๊ฒฝํ—˜๊ณผ ์‚ฌ์‹ค์— ์˜์กดํ•˜๋Š” ํŽธ์ด๋‹ค.", "B. ์ง๊ด€๊ณผ ๊ฐ€๋Šฅ์„ฑ์„ ๊ณ ๋ คํ•˜๋Š” ํŽธ์ด๋‹ค."],
"scale": "SN", # S=A, N=B
},
{
"question": "3. ๊ฒฐ์ •์„ ๋‚ด๋ฆด ๋•Œ, ๋‹น์‹ ์€:",
"options": ["A. ๋…ผ๋ฆฌ์™€ ๊ฐ๊ด€์  ์‚ฌ์‹ค์„ ์ค‘์‹œํ•œ๋‹ค.", "B. ๊ฐ์ •๊ณผ ๊ด€๊ณ„๋ฅผ ๊ณ ๋ คํ•œ๋‹ค."],
"scale": "TF", # T=A, F=B
},
{
"question": "4. ์ผ์ƒ ์ƒํ™œ์—์„œ, ๋‹น์‹ ์€:",
"options": ["A. ๊ณ„ํš์„ ์„ธ์šฐ๊ณ  ์ฒด๊ณ„์ ์œผ๋กœ ํ–‰๋™ํ•œ๋‹ค.", "B. ์œ ์—ฐํ•˜๊ฒŒ ์ƒํ™ฉ์— ๋”ฐ๋ผ ๋Œ€์ฒ˜ํ•œ๋‹ค."],
"scale": "JP", # J=A, P=B
},
{
"question": "5. ์ฃผ๋ง ๊ณ„ํš์€:",
"options": ["A. ์นœ๊ตฌ๋“ค๊ณผ ๋งŒ๋‚˜๊ฑฐ๋‚˜ ์™ธ๋ถ€ ํ™œ๋™์„ ์„ ํ˜ธํ•œ๋‹ค.", "B. ํ˜ผ์ž ์žˆ๊ฑฐ๋‚˜ ์†Œ์ˆ˜์˜ ์นœํ•œ ์‚ฌ๋žŒ๊ณผ ๋ณด๋‚ด๋Š” ๊ฒƒ์„ ์„ ํ˜ธํ•œ๋‹ค."],
"scale": "EI", # E=A, I=B
},
{
"question": "6. ๊ด€์‹ฌ์„ ๊ฐ–๋Š” ์ฃผ์ œ๋Š”:",
"options": ["A. ๊ตฌ์ฒด์ ์ด๊ณ  ์‹ค์งˆ์ ์ธ ๊ฒƒ๋“ค์ด๋‹ค.", "B. ์ถ”์ƒ์ ์ด๊ณ  ๊ฐœ๋…์ ์ธ ๊ฒƒ๋“ค์ด๋‹ค."],
"scale": "SN", # S=A, N=B
},
{
"question": "7. ๊ฐˆ๋“ฑ ์ƒํ™ฉ์—์„œ, ๋‹น์‹ ์€:",
"options": ["A. ๊ฐ๊ด€์  ์‚ฌ์‹ค์„ ๋ฐ”ํƒ•์œผ๋กœ ๋…ผ๋ฆฌ์ ์œผ๋กœ ์ ‘๊ทผํ•œ๋‹ค.", "B. ๊ฐ์ •๊ณผ ์กฐํ™”๋ฅผ ๊ณ ๋ คํ•˜์—ฌ ์ ‘๊ทผํ•œ๋‹ค."],
"scale": "TF", # T=A, F=B
},
{
"question": "8. ์—ฌํ–‰์„ ๊ฐˆ ๋•Œ, ๋‹น์‹ ์€:",
"options": ["A. ์„ธ๋ถ€ ์ผ์ •์„ ๋ฏธ๋ฆฌ ๊ณ„ํšํ•œ๋‹ค.", "B. ๋Œ€๋žต์ ์ธ ๋ฐฉํ–ฅ๋งŒ ์ •ํ•˜๊ณ  ์ฆ‰ํฅ์ ์œผ๋กœ ๊ฒฐ์ •ํ•œ๋‹ค."],
"scale": "JP", # J=A, P=B
},
{
"question": "9. ๋Œ€ํ™”์—์„œ, ๋‹น์‹ ์€:",
"options": ["A. ๋‹ค์–‘ํ•œ ์ฃผ์ œ๋กœ ํญ๋„“๊ฒŒ ์ด์•ผ๊ธฐํ•˜๋Š” ๊ฒƒ์„ ์ฆ๊ธด๋‹ค.", "B. ํŠน์ • ์ฃผ์ œ์— ๋Œ€ํ•ด ๊นŠ์ด ์žˆ๊ฒŒ ์ด์•ผ๊ธฐํ•˜๋Š” ๊ฒƒ์„ ์ฆ๊ธด๋‹ค."],
"scale": "EI", # E=A, I=B
},
{
"question": "10. ์ƒˆ๋กœ์šด ์ •๋ณด๋ฅผ ๋ฐ›์•„๋“ค์ผ ๋•Œ, ๋‹น์‹ ์€:",
"options": ["A. ์‹ค์šฉ์ ์ธ ์šฉ๋„์™€ ํ˜„์‹ค์  ์ ์šฉ์— ์ดˆ์ ์„ ๋งž์ถ˜๋‹ค.", "B. ํŒจํ„ด์„ ์ฐพ๊ณ  ์ „์ฒด์ ์ธ ์˜๋ฏธ๋ฅผ ํŒŒ์•…ํ•˜๋ ค ํ•œ๋‹ค."],
"scale": "SN", # S=A, N=B
},
]
mbti_descriptions = {
"ISTJ": {
"title": "์ฒญ๋ ด๊ฒฐ๋ฐฑํ•œ ๋…ผ๋ฆฌ์ฃผ์˜์ž (ISTJ)",
"description": "์‚ฌ์‹ค์„ ์ค‘์‹œํ•˜๋Š” ๋ฏฟ์Œ์งํ•œ ํ˜„์‹ค์ฃผ์˜์ž์ž…๋‹ˆ๋‹ค. ์ฑ…์ž„๊ฐ์ด ๊ฐ•ํ•˜๊ณ  ์ฒด๊ณ„์ ์ด๋ฉฐ ๋…ผ๋ฆฌ์ ์ธ ์‚ฌ๊ณ ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์—…๋ฌด๋ฅผ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "์ฒด๊ณ„์ , ์‹ ๋ขฐ์„ฑ, ํ˜„์‹ค์ , ์ฑ…์ž„๊ฐ",
"weaknesses": "์œตํ†ต์„ฑ ๋ถ€์กฑ, ์ง€๋‚˜์นœ ์™„๋ฒฝ์ฃผ์˜, ๊ฐ์ • ํ‘œํ˜„์˜ ์–ด๋ ค์›€",
"relationships": "์‹ ๋ขฐ์™€ ์ฑ…์ž„๊ฐ์„ ๋ฐ”ํƒ•์œผ๋กœ ์•ˆ์ •์ ์ธ ๊ด€๊ณ„๋ฅผ ์œ ์ง€ํ•ฉ๋‹ˆ๋‹ค. ์†”์งํ•˜๊ณ  ์ง์ ‘์ ์ธ ์˜์‚ฌ์†Œํ†ต์„ ์„ ํ˜ธํ•ฉ๋‹ˆ๋‹ค.",
"famous": "ํ€ธ ์—˜๋ฆฌ์ž๋ฒ ์Šค 2์„ธ, ์›Œ๋ Œ ๋ฒ„ํ•, ๋งˆ์ดํด ์กฐ๋˜",
"careers": "ํšŒ๊ณ„์‚ฌ, ์—”์ง€๋‹ˆ์–ด, ํ”„๋กœ์ ํŠธ ๋งค๋‹ˆ์ €, ๊ตฐ์ธ, ๋ฒ•๋ฅ ๊ฐ€"
},
"ISFJ": {
"title": "์šฉ๊ฐํ•œ ์ˆ˜ํ˜ธ์ž (ISFJ)",
"description": "ํ—Œ์‹ ์ ์ด๊ณ  ๋”ฐ๋œปํ•œ ์ˆ˜ํ˜ธ์ž์ž…๋‹ˆ๋‹ค. ์ฑ…์ž„๊ฐ์ด ๊ฐ•ํ•˜๋ฉฐ ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ํ•„์š”์— ๋ฏผ๊ฐํ•˜๊ฒŒ ๋ฐ˜์‘ํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "์‹ ๋ขฐ์„ฑ, ์‹ค์šฉ์„ฑ, ํ—Œ์‹ ์ , ์„ธ์‹ฌํ•จ",
"weaknesses": "๋ณ€ํ™”์— ๋Œ€ํ•œ ์ €ํ•ญ, ์ž๊ธฐ ์ฃผ์žฅ ๋ถ€์กฑ, ๊ณผ๋„ํ•œ ์ž๊ธฐ ํฌ์ƒ",
"relationships": "๊นŠ๊ณ  ์˜๋ฏธ ์žˆ๋Š” ๊ด€๊ณ„๋ฅผ ์ถ”๊ตฌํ•˜๋ฉฐ, ๊ฐ€์กฑ๊ณผ ์นœ๊ตฌ๋“ค์—๊ฒŒ ํ—Œ์‹ ์ ์ž…๋‹ˆ๋‹ค.",
"famous": "์ผ€์ดํŠธ ๋ฏธ๋“คํ„ด, ๋งˆ๋” ํ…Œ๋ ˆ์‚ฌ, ๋กœ์‚ฌ ํŒŒํฌ์Šค",
"careers": "๊ฐ„ํ˜ธ์‚ฌ, ๊ต์‚ฌ, ์‚ฌํšŒ๋ณต์ง€์‚ฌ, ํ–‰์ • ์ง€์›, ์ธ์‚ฌ ๋‹ด๋‹น์ž"
},
"INFJ": {
"title": "์„ ์˜์˜ ์˜นํ˜ธ์ž (INFJ)",
"description": "์ด์ƒ์ฃผ์˜์ ์ด๊ณ  ์›์น™์ ์ธ ์‚ฌ๋žŒ์œผ๋กœ, ์ธ๋ฅ˜๋ฅผ ์œ„ํ•œ ๋” ๋‚˜์€ ๋ฏธ๋ž˜๋ฅผ ๊ฟˆ๊ฟ‰๋‹ˆ๋‹ค. ๊นŠ์€ ํ†ต์ฐฐ๋ ฅ๊ณผ ์ง๊ด€๋ ฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.",
"strengths": "์ฐฝ์˜์„ฑ, ํ†ต์ฐฐ๋ ฅ, ํ™•๊ณ ํ•œ ์›์น™, ์—ด์ •์ ",
"weaknesses": "์™„๋ฒฝ์ฃผ์˜, ๋ฒˆ์•„์›ƒ ๊ฒฝํ–ฅ, ์ง€๋‚˜์นœ ์ด์ƒ์ฃผ์˜",
"relationships": "๊นŠ๊ณ  ์˜๋ฏธ ์žˆ๋Š” ๊ด€๊ณ„๋ฅผ ์ถ”๊ตฌํ•˜๋ฉฐ, ์ง„์ •์„ฑ ์žˆ๋Š” ์†Œํ†ต์„ ์ค‘์š”์‹œํ•ฉ๋‹ˆ๋‹ค.",
"famous": "๋งˆํ‹ด ๋ฃจํ„ฐ ํ‚น, ๋„ฌ์Šจ ๋งŒ๋ธ๋ผ, ๋ ˆ์ด๋”” ๊ฐ€๊ฐ€",
"careers": "์ƒ๋‹ด์‚ฌ, ์ž‘๊ฐ€, ์‹ฌ๋ฆฌํ•™์ž, ๊ต์ˆ˜, ๋น„์˜๋ฆฌ ๋‹จ์ฒด ํ™œ๋™๊ฐ€"
},
"INTJ": {
"title": "์šฉ์˜์ฃผ๋„ํ•œ ์ „๋žต๊ฐ€ (INTJ)",
"description": "๋…์ฐฝ์ ์ธ ์ „๋žต๊ฐ€๋กœ, ๋ถ„์„์ ์ด๊ณ  ๋…๋ฆฝ์ ์ž…๋‹ˆ๋‹ค. ๋น„์ „์„ ๊ฐ€์ง€๊ณ  ์„ธ์ƒ์„ ๋ฐ”๋ผ๋ณด๋ฉฐ ์ง€์‹ ์ถ”๊ตฌ์— ์—ด์ •์ ์ž…๋‹ˆ๋‹ค.",
"strengths": "๋ถ„์„๋ ฅ, ๋…์ฐฝ์„ฑ, ์ž์‹ ๊ฐ, ๋…๋ฆฝ์„ฑ",
"weaknesses": "์ง€๋‚˜์นœ ์™„๋ฒฝ์ฃผ์˜, ๋น„ํŒ์  ์„ฑํ–ฅ, ๊ณ ์ง‘",
"relationships": "์ง€์  ๊ต๋ฅ˜๊ฐ€ ์žˆ๋Š” ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•˜๋ฉฐ, ๊ฐ์ • ํ‘œํ˜„์ด ์ง์ ‘์ ์ด์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.",
"famous": "์ผ๋ก  ๋จธ์Šคํฌ, ๋งˆํฌ ์ €์ปค๋ฒ„๊ทธ, ํฌ๋ฆฌ์Šคํ† ํผ ๋†€๋ž€",
"careers": "๊ณผํ•™์ž, ์—”์ง€๋‹ˆ์–ด, ํ”„๋กœ๊ทธ๋ž˜๋จธ, ์ „๋žต ์ปจ์„คํ„ดํŠธ, ๊ฑด์ถ•๊ฐ€"
},
"ISTP": {
"title": "๋งŒ๋Šฅ ์žฌ์ฃผ๊พผ (ISTP)",
"description": "๋Œ€๋‹ดํ•œ ์‹ค์šฉ์ฃผ์˜์ž๋กœ, ๋‹ค์–‘ํ•œ ๋„๊ตฌ๋ฅผ ๋Šฅ์ˆ™ํ•˜๊ฒŒ ๋‹ค๋ฃน๋‹ˆ๋‹ค. ๋ฌธ์ œ ํ•ด๊ฒฐ์— ๋›ฐ์–ด๋‚˜๋ฉฐ ์œ„๊ธฐ ์ƒํ™ฉ์—์„œ ์นจ์ฐฉํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "์‹ค์šฉ์„ฑ, ์ ์‘๋ ฅ, ๋ฌธ์ œ ํ•ด๊ฒฐ ๋Šฅ๋ ฅ, ํ˜ธ๊ธฐ์‹ฌ",
"weaknesses": "์ถฉ๋™์  ๊ฒฝํ–ฅ, ํ—Œ์‹ ์˜ ์–ด๋ ค์›€, ๊ฐ์ • ํ‘œํ˜„ ๋ถ€์กฑ",
"relationships": "๊ฐœ์ธ ๊ณต๊ฐ„์„ ์ค‘์š”์‹œํ•˜๋ฉฐ, ์••๋ฐ• ์—†๋Š” ์ž์œ ๋กœ์šด ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•ฉ๋‹ˆ๋‹ค.",
"famous": "ํ†ฐ ํฌ๋ฃจ์ฆˆ, ํด๋ฆฐํŠธ ์ด์ŠคํŠธ์šฐ๋“œ, ๋งˆ์ดํด ์กฐ๋˜",
"careers": "๊ธฐ๊ณ„๊ณต, ์—”์ง€๋‹ˆ์–ด, ํŒŒ์ผ๋Ÿฟ, ์šด๋™์„ ์ˆ˜, ๋ฐ์ดํ„ฐ ๋ถ„์„๊ฐ€"
},
"ISFP": {
"title": "ํ˜ธ๊ธฐ์‹ฌ ๋งŽ์€ ์˜ˆ์ˆ ๊ฐ€ (ISFP)",
"description": "์ž์œ ๋กœ์šด ์˜ํ˜ผ์„ ๊ฐ€์ง„ ์˜ˆ์ˆ ๊ฐ€์ž…๋‹ˆ๋‹ค. ๊ฐ์„ฑ์ ์ด๊ณ  ์˜จํ™”ํ•˜๋ฉฐ ํ˜„์žฌ์˜ ์ˆœ๊ฐ„์„ ์ฆ๊ธฐ๋Š” ์„ฑํ–ฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.",
"strengths": "์ฐฝ์˜์„ฑ, ๊ฐ์ˆ˜์„ฑ, ์ถฉ์‹คํ•จ, ์ ์‘๋ ฅ",
"weaknesses": "์žฅ๊ธฐ ๊ณ„ํš์˜ ์–ด๋ ค์›€, ๊ฐˆ๋“ฑ ํšŒํ”ผ, ์ง€๋‚˜์นœ ๊ฒธ์†",
"relationships": "์กฐํ™”๋กญ๊ณ  ๋น„ํŒ์ ์ด์ง€ ์•Š์€ ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•˜๋ฉฐ, ํ–‰๋™์œผ๋กœ ์• ์ •์„ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค.",
"famous": "๋ฐฅ ๋”œ๋Ÿฐ, ๋ฐ์ด๋น„๋“œ ๋ณด์œ„, ํ”„๋ฆฌ๋‹ค ์นผ๋กœ",
"careers": "์˜ˆ์ˆ ๊ฐ€, ๋””์ž์ด๋„ˆ, ์Œ์•…๊ฐ€, ์‚ฌ์ง„์ž‘๊ฐ€, ํ—ค์–ด์Šคํƒ€์ผ๋ฆฌ์ŠคํŠธ"
},
"INFP": {
"title": "์—ด์ •์ ์ธ ์ค‘์žฌ์ž (INFP)",
"description": "์ด์ƒ์ฃผ์˜์ ์ด๊ณ  ๊ณต๊ฐ ๋Šฅ๋ ฅ์ด ๋›ฐ์–ด๋‚œ ์ค‘์žฌ์ž์ž…๋‹ˆ๋‹ค. ๊นŠ์€ ๊ฐœ์ธ์  ๊ฐ€์น˜์™€ ์—ด์ •์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.",
"strengths": "์ฐฝ์˜์„ฑ, ๊ณต๊ฐ ๋Šฅ๋ ฅ, ์ด์ƒ์ฃผ์˜, ์ ์‘๋ ฅ",
"weaknesses": "๋น„ํ˜„์‹ค์  ๊ธฐ๋Œ€, ๊ฐ์ •์  ๋™์š”, ์ž๊ธฐ ๋น„ํŒ",
"relationships": "๊นŠ๊ณ  ์˜๋ฏธ ์žˆ๋Š” ๊ด€๊ณ„๋ฅผ ์ถ”๊ตฌํ•˜๋ฉฐ, ์ง„์ •์„ฑ๊ณผ ๊ฐœ์ธ์  ์„ฑ์žฅ์„ ์ค‘์š”์‹œํ•ฉ๋‹ˆ๋‹ค.",
"famous": "์œŒ๋ฆฌ์—„ ์…ฐ์ต์Šคํ”ผ์–ด, ํ†จํ‚จ, ์˜ค๋“œ๋ฆฌ ํ—ต๋ฒˆ",
"careers": "์ž‘๊ฐ€, ์‹ฌ๋ฆฌ์ƒ๋‹ด์‚ฌ, ๊ต์‚ฌ, ์˜ˆ์ˆ ๊ฐ€, ์Œ์•…๊ฐ€"
},
"INTP": {
"title": "๋…ผ๋ฆฌ์ ์ธ ์‚ฌ์ƒ‰๊ฐ€ (INTP)",
"description": "ํ˜์‹ ์ ์ธ ๋ฐœ๋ช…๊ฐ€๋กœ, ์ง€์‹์— ๋ชฉ๋งˆ๋ฅด๊ณ  ๋…ผ๋ฆฌ์ ์ž…๋‹ˆ๋‹ค. ๋ณต์žกํ•œ ๋ฌธ์ œ์™€ ์ด๋ก ์  ๊ฐœ๋…์— ๋งค๋ฃŒ๋ฉ๋‹ˆ๋‹ค.",
"strengths": "๋ถ„์„๋ ฅ, ์ฐฝ์˜์„ฑ, ๋…์ฐฝ์„ฑ, ๊ฐœ๋ฐฉ์„ฑ",
"weaknesses": "์‹คํ–‰์˜ ์–ด๋ ค์›€, ์‚ฌํšŒ์  ์ƒํ˜ธ์ž‘์šฉ์˜ ๋ถˆํŽธํ•จ, ์ง‘์ค‘๋ ฅ ๋ถ„์‚ฐ",
"relationships": "์ง€์  ์ž๊ทน์„ ์ฃผ๋Š” ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•˜๋ฉฐ, ๊ฐ์ • ํ‘œํ˜„์ด ์„œํˆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.",
"famous": "์•Œ๋ฒ ๋ฅดํŠธ ์•„์ธ์Šˆํƒ€์ธ, ์—์ด๋ธŒ๋Ÿฌํ–„ ๋ง์ปจ, ๋นŒ ๊ฒŒ์ด์ธ ",
"careers": "๊ณผํ•™์ž, ํ”„๋กœ๊ทธ๋ž˜๋จธ, ์ˆ˜ํ•™์ž, ์ฒ ํ•™์ž, ์—ฐ๊ตฌ์›"
},
"ESTP": {
"title": "๋ชจํ—˜์„ ์ฆ๊ธฐ๋Š” ์‚ฌ์—…๊ฐ€ (ESTP)",
"description": "๋Œ€๋‹ดํ•œ ์‚ฌ์—…๊ฐ€๋กœ, ํ™œ๋™์ ์ด๊ณ  ํ˜„์‹ค์ ์ž…๋‹ˆ๋‹ค. ์ˆœ๋ฐœ๋ ฅ์ด ์ข‹๊ณ  ์œ„ํ—˜์„ ๊ฐ์ˆ˜ํ•˜๋Š” ๊ฒƒ์„ ๋‘๋ ค์›Œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.",
"strengths": "๋Œ€๋‹ดํ•จ, ์ ์‘๋ ฅ, ์‹ค์šฉ์„ฑ, ํ˜„์‹ค๊ฐ๊ฐ",
"weaknesses": "์ธ๋‚ด์‹ฌ ๋ถ€์กฑ, ๊ณ„ํš์„ฑ ๋ถ€์กฑ, ์ถฉ๋™์  ๊ฒฐ์ •",
"relationships": "ํ™œ๊ธฐ์ฐจ๊ณ  ํฅ๋ฏธ๋กœ์šด ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•˜๋ฉฐ, ์‹ค์šฉ์ ์ด๊ณ  ์ง์ ‘์ ์ธ ์˜์‚ฌ์†Œํ†ต์„ ํ•ฉ๋‹ˆ๋‹ค.",
"famous": "๋„๋„๋“œ ํŠธ๋Ÿผํ”„, ๋งˆ๋ˆ๋‚˜, ์žญ ๋‹ˆ์ฝœ์Šจ",
"careers": "๊ธฐ์—…๊ฐ€, ์„ธ์ผ์ฆˆ๋งจ, ๋งˆ์ผ€ํ„ฐ, ๊ฒฝ์˜์ž, ์šด๋™์„ ์ˆ˜"
},
"ESFP": {
"title": "์ž์œ ๋กœ์šด ์˜ํ˜ผ์˜ ์—ฐ์˜ˆ์ธ (ESFP)",
"description": "์ฆ‰ํฅ์ ์ด๊ณ  ์—ด์ •์ ์ธ ์—ฐ์˜ˆ์ธ์ž…๋‹ˆ๋‹ค. ํ™œ๊ธฐ์ฐจ๊ณ  ๋งค๋ ฅ์ ์ด๋ฉฐ ์ˆœ๊ฐ„์„ ์ฆ๊ธฐ๋Š” ์„ฑํ–ฅ์ด ์žˆ์Šต๋‹ˆ๋‹ค.",
"strengths": "์—ด์ •, ์‚ฌ๊ต์„ฑ, ๋‚™๊ด€์„ฑ, ์‹ค์šฉ์„ฑ",
"weaknesses": "์žฅ๊ธฐ ๊ณ„ํš์˜ ์–ด๋ ค์›€, ์‹ฌ๊ฐํ•œ ์ฃผ์ œ ํšŒํ”ผ, ์ง€๋‚˜์นœ ์ฆ‰ํฅ์„ฑ",
"relationships": "์ฆ๊ฒ๊ณ  ํ™œ๊ธฐ์ฐฌ ๊ด€๊ณ„๋ฅผ ์ถ”๊ตฌํ•˜๋ฉฐ, ๊ด€๋Œ€ํ•˜๊ณ  ์ˆ˜์šฉ์ ์ธ ํƒœ๋„๋ฅผ ๋ณด์ž…๋‹ˆ๋‹ค.",
"famous": "์—˜๋น„์Šค ํ”„๋ ˆ์Šฌ๋ฆฌ, ์•„๋ธ, ์ œ์ด๋ฏธ ์˜ฌ๋ฆฌ๋ฒ„",
"careers": "์—ฐ์˜ˆ์ธ, ํ˜ธํ…”๋ฆฌ์–ด, ์ด๋ฒคํŠธ ํ”Œ๋ž˜๋„ˆ, ์„ธ์ผ์ฆˆ๋งจ, ์š”๋ฆฌ์‚ฌ"
},
"ENFP": {
"title": "์žฌ๊ธฐ๋ฐœ๋ž„ํ•œ ํ™œ๋™๊ฐ€ (ENFP)",
"description": "์—ด์ •์ ์ด๊ณ  ์ฐฝ์˜์ ์ธ ์ž์œ  ์˜ํ˜ผ์ž…๋‹ˆ๋‹ค. ๊ฐ€๋Šฅ์„ฑ์„ ๋ณด๋Š” ๋ˆˆ์ด ๋›ฐ์–ด๋‚˜๋ฉฐ ์ƒˆ๋กœ์šด ์•„์ด๋””์–ด์™€ ์‚ฌ๋žŒ๋“ค์—๊ฒŒ ์—ด์ •์ ์ž…๋‹ˆ๋‹ค.",
"strengths": "์—ด์ •, ์ฐฝ์˜์„ฑ, ์‚ฌ๊ต์„ฑ, ์ ์‘๋ ฅ",
"weaknesses": "์ง‘์ค‘๋ ฅ ๋ถ€์กฑ, ํ˜„์‹ค์  ์„ธ๋ถ€์‚ฌํ•ญ ๊ฐ„๊ณผ, ๊ณผ๋„ํ•œ ๋…๋ฆฝ์‹ฌ",
"relationships": "๊นŠ๊ณ  ์˜๋ฏธ ์žˆ๋Š” ๊ด€๊ณ„๋ฅผ ์ถ”๊ตฌํ•˜๋ฉฐ, ์ƒ๋Œ€๋ฐฉ์˜ ์„ฑ์žฅ์„ ๋•๋Š”๋ฐ ์—ด์ •์ ์ž…๋‹ˆ๋‹ค.",
"famous": "๋กœ๋นˆ ์œŒ๋ฆฌ์—„์Šค, ์›”ํŠธ ๋””์ฆˆ๋‹ˆ, ์—˜๋Ÿฐ ๋””์ œ๋„ˆ๋Ÿฌ์Šค",
"careers": "์ฝ”์น˜, ๊ธฐ์—…๊ฐ€, ๋งˆ์ผ€ํ„ฐ, ์•„ํ‹ฐ์ŠคํŠธ, ์ €๋„๋ฆฌ์ŠคํŠธ"
},
"ENTP": {
"title": "๋…ผ์Ÿ์„ ์ฆ๊ธฐ๋Š” ๋ณ€๋ก ๊ฐ€ (ENTP)",
"description": "์˜๋ฆฌํ•˜๊ณ  ํ˜ธ๊ธฐ์‹ฌ ๋งŽ์€ ์‚ฌ์ƒ๊ฐ€์ž…๋‹ˆ๋‹ค. ์ง€์  ๋„์ „์„ ์ฆ๊ธฐ๋ฉฐ ์ƒˆ๋กœ์šด ์•„์ด๋””์–ด์™€ ๊ฐ€๋Šฅ์„ฑ์„ ํƒ์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "์ฐฝ์˜์„ฑ, ์ ์‘๋ ฅ, ๋…ผ๋ฆฌ๋ ฅ, ์ง€์  ํ˜ธ๊ธฐ์‹ฌ",
"weaknesses": "์ผ๊ด€์„ฑ ๋ถ€์กฑ, ๋…ผ์Ÿ์  ์„ฑํ–ฅ, ์‹คํ–‰๋ ฅ ๋ถ€์กฑ",
"relationships": "์ง€์ ์œผ๋กœ ์ž๊ทน์ ์ธ ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•˜๋ฉฐ, ๋‹ค์–‘ํ•œ ์ฃผ์ œ์— ๋Œ€ํ•œ ์—ด๋ฆฐ ํ† ๋ก ์„ ์ฆ๊น๋‹ˆ๋‹ค.",
"famous": "์Šคํ‹ฐ๋ธŒ ์žก์Šค, ๋ฆฌ์ฒ˜๋“œ ํŒŒ์ธ๋งŒ, ๋กœ๋ฒ„ํŠธ ๋‹ค์šฐ๋‹ˆ ์ฃผ๋‹ˆ์–ด",
"careers": "๊ธฐ์—…๊ฐ€, ๋ณ€ํ˜ธ์‚ฌ, ๋ฐœ๋ช…๊ฐ€, ๋งˆ์ผ€ํ„ฐ, ์—”์ง€๋‹ˆ์–ด"
},
"ESTJ": {
"title": "์—„๊ฒฉํ•œ ๊ด€๋ฆฌ์ž (ESTJ)",
"description": "์ฒด๊ณ„์ ์ด๊ณ  ์‹ค์šฉ์ ์ธ ๊ด€๋ฆฌ์ž์ž…๋‹ˆ๋‹ค. ์ „ํ†ต๊ณผ ์งˆ์„œ๋ฅผ ์ค‘์‹œํ•˜๋ฉฐ ๋ชฉํ‘œ ๋‹ฌ์„ฑ์„ ์œ„ํ•ด ํšจ์œจ์ ์œผ๋กœ ํ–‰๋™ํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "์กฐ์ง๋ ฅ, ์ฑ…์ž„๊ฐ, ๊ฒฐ๋‹จ๋ ฅ, ์‹ ๋ขฐ์„ฑ",
"weaknesses": "์œตํ†ต์„ฑ ๋ถ€์กฑ, ๊ฐ์ •์— ๋‘”๊ฐ, ์ง€๋‚˜์นœ ์ง€๋ฐฐ๋ ฅ",
"relationships": "๋ช…ํ™•ํ•œ ์—ญํ• ๊ณผ ์ฑ…์ž„์ด ์žˆ๋Š” ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•˜๋ฉฐ, ์ง์ ‘์ ์ด๊ณ  ์†”์งํ•œ ์˜์‚ฌ์†Œํ†ต์„ ํ•ฉ๋‹ˆ๋‹ค.",
"famous": "๋ฏธ์…ธ ์˜ค๋ฐ”๋งˆ, ์•ค๋“œ๋ฅ˜ ์นด๋„ค๊ธฐ, ๊ณ ๋“  ๋žจ์ง€",
"careers": "๋งค๋‹ˆ์ €, ๊ฒฝ์˜์ž, ๊ตฐ์ธ, ํŒ์‚ฌ, ์žฌ์ • ๋ถ„์„๊ฐ€"
},
"ESFJ": {
"title": "์‚ฌ๊ต์ ์ธ ์™ธ๊ต๊ด€ (ESFJ)",
"description": "๋ฐฐ๋ ค์‹ฌ ๊นŠ๊ณ  ์‚ฌ๊ต์ ์ธ ๋ณด์‚ดํ•Œ ์ œ๊ณต์ž์ž…๋‹ˆ๋‹ค. ์กฐํ™”์™€ ํ˜‘๋ ฅ์„ ์ค‘์‹œํ•˜๋ฉฐ ํƒ€์ธ์˜ ํ•„์š”์— ๋ฏผ๊ฐํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "ํ˜‘๋ ฅ, ์ถฉ์‹คํ•จ, ๋ฐฐ๋ ค์‹ฌ, ์‹ค์šฉ์„ฑ",
"weaknesses": "๋น„ํŒ์— ๋ฏผ๊ฐ, ๊ฐˆ๋“ฑ ํšŒํ”ผ, ๊ณผ๋„ํ•œ ์ž๊ธฐํฌ์ƒ",
"relationships": "ํ™”ํ•ฉ๊ณผ ์•ˆ์ •์„ ์ค‘์‹œํ•˜๋Š” ๊ด€๊ณ„๋ฅผ ์ถ”๊ตฌํ•˜๋ฉฐ, ์ฃผ๋ณ€ ์‚ฌ๋žŒ๋“ค์„ ๋ณด์‚ดํ”ผ๋Š”๋ฐ ์—ด์ •์ ์ž…๋‹ˆ๋‹ค.",
"famous": "ํ…Œ์ผ๋Ÿฌ ์Šค์œ„ํ”„ํŠธ, ๋นŒ ํด๋ฆฐํ„ด, ์ œ๋‹ˆํผ ๋กœํŽ˜์ฆˆ",
"careers": "๊ต์‚ฌ, ๊ฐ„ํ˜ธ์‚ฌ, ์ธ์‚ฌ ๊ด€๋ฆฌ์ž, ์‚ฌํšŒ๋ณต์ง€์‚ฌ, ์ด๋ฒคํŠธ ํ”Œ๋ž˜๋„ˆ"
},
"ENFJ": {
"title": "์ •์˜๋กœ์šด ์‚ฌํšŒ์šด๋™๊ฐ€ (ENFJ)",
"description": "์นด๋ฆฌ์Šค๋งˆ ์žˆ๋Š” ์ง€๋„์ž๋กœ, ์˜๊ฐ์„ ์ฃผ๊ณ  ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ์„ฑ์žฅ์„ ๋•์Šต๋‹ˆ๋‹ค. ์‚ฌ๋žŒ๋“ค์˜ ์ž ์žฌ๋ ฅ์„ ๋ณด๊ณ  ๊ทธ๋“ค์„ ๋™๊ธฐ๋ถ€์—ฌํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "๊ณต๊ฐ ๋Šฅ๋ ฅ, ๋ฆฌ๋”์‹ญ, ์˜ํ–ฅ๋ ฅ, ์ ์‘๋ ฅ",
"weaknesses": "๊ณผ๋„ํ•œ ์ด์ƒ์ฃผ์˜, ๋น„ํŒ์— ๋ฏผ๊ฐ, ์ž๊ธฐ ์†Œํ™€",
"relationships": "์ง„์ •์„ฑ ์žˆ๊ณ  ์˜๋ฏธ ์žˆ๋Š” ๊ด€๊ณ„๋ฅผ ์ถ”๊ตฌํ•˜๋ฉฐ, ์ƒ๋Œ€๋ฐฉ์˜ ์„ฑ์žฅ๊ณผ ํ–‰๋ณต์„ ๋•๋Š”๋ฐ ํ—Œ์‹ ํ•ฉ๋‹ˆ๋‹ค.",
"famous": "์˜คํ”„๋ผ ์œˆํ”„๋ฆฌ, ๋ฒ„๋ฝ ์˜ค๋ฐ”๋งˆ, ์กด ๋ ˆ๋…ผ",
"careers": "๊ต์œก์ž, ์ƒ๋‹ด์‚ฌ, ์ธ์‚ฌ ๊ด€๋ฆฌ์ž, ๋งˆ์ผ€ํ„ฐ, ์ •์น˜์ธ"
},
"ENTJ": {
"title": "๋Œ€๋‹ดํ•œ ํ†ต์†”์ž (ENTJ)",
"description": "๊ณผ๊ฐํ•˜๊ณ  ์ƒ์ƒ๋ ฅ ํ’๋ถ€ํ•œ ์ง€๋„์ž์ž…๋‹ˆ๋‹ค. ๊ฒฐ๋‹จ๋ ฅ ์žˆ๊ณ  ์ง์ ‘์ ์ด๋ฉฐ ๋ชฉํ‘œ ๋‹ฌ์„ฑ์„ ์œ„ํ•ด ํšจ์œจ์ ์œผ๋กœ ์ผํ•ฉ๋‹ˆ๋‹ค.",
"strengths": "๋ฆฌ๋”์‹ญ, ๊ฒฐ๋‹จ๋ ฅ, ์ „๋žต์  ์‚ฌ๊ณ , ์ž์‹ ๊ฐ",
"weaknesses": "์ฐธ์„์„ฑ ๋ถ€์กฑ, ์ง€๋‚˜์นœ ์ง€๋ฐฐ๋ ฅ, ๊ฐ์ •์— ๋‘”๊ฐ",
"relationships": "๋ชฉํ‘œ ์ง€ํ–ฅ์ ์ด๊ณ  ์ง€์ ์ธ ๊ด€๊ณ„๋ฅผ ์„ ํ˜ธํ•˜๋ฉฐ, ์ง์ ‘์ ์ด๊ณ  ์†”์งํ•œ ์˜์‚ฌ์†Œํ†ต์„ ํ•ฉ๋‹ˆ๋‹ค.",
"famous": "์Šคํ‹ฐ๋ธŒ ์žก์Šค, ๋งˆ๊ฐ€๋ › ๋Œ€์ฒ˜, ํ”„๋žญํด๋ฆฐ D. ๋ฃจ์ฆˆ๋ฒจํŠธ",
"careers": "๊ฒฝ์˜์ž, ๊ธฐ์—…๊ฐ€, ๋ณ€ํ˜ธ์‚ฌ, ์ปจ์„คํ„ดํŠธ, ์ •์น˜์ธ"
}
}
def calculate_mbti(scores):
mbti = ""
mbti += "E" if scores["EI"] > 0 else "I"
mbti += "S" if scores["SN"] > 0 else "N"
mbti += "T" if scores["TF"] > 0 else "F"
mbti += "J" if scores["JP"] > 0 else "P"
return mbti
with gr.Blocks(theme=gr.themes.Soft()) as app:
# ์ƒํƒœ ๊ด€๋ฆฌ
state = gr.State({
"current_question": 0,
"scores": {"EI": 0, "SN": 0, "TF": 0, "JP": 0},
"completed": False
})
# ํ—ค๋” ์„น์…˜
gr.Markdown("# MBTI ์„ฑ๊ฒฉ ์œ ํ˜• ์ง„๋‹จ")
with gr.Column():
intro = gr.Markdown("""
์ด ํ…Œ์ŠคํŠธ๋Š” ๋‹น์‹ ์˜ MBTI ์„ฑ๊ฒฉ ์œ ํ˜•์„ ์ง„๋‹จํ•˜๋Š” ๊ฐ„๋‹จํ•œ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค.
10๊ฐœ์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋ฉด 16๊ฐ€์ง€ MBTI ์„ฑ๊ฒฉ ์œ ํ˜• ์ค‘ ๋‹น์‹ ์—๊ฒŒ ๊ฐ€์žฅ ์ ํ•ฉํ•œ ์œ ํ˜•์„ ์•Œ๋ ค๋“œ๋ฆฝ๋‹ˆ๋‹ค.
* ๊ฐ ์งˆ๋ฌธ์—๋Š” A ๋˜๋Š” B ๋‘ ๊ฐ€์ง€ ์„ ํƒ์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
* ์ž์‹ ๊ณผ ๊ฐ€์žฅ ๊ฐ€๊น๋‹ค๊ณ  ์ƒ๊ฐ๋˜๋Š” ๋‹ต๋ณ€์„ ์†”์งํ•˜๊ฒŒ ์„ ํƒํ•ด์ฃผ์„ธ์š”.
* ๋ชจ๋“  ์งˆ๋ฌธ์— ๋‹ตํ•˜๋ฉด ์ƒ์„ธํ•œ ์„ฑ๊ฒฉ ์œ ํ˜• ๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
""")
start_button = gr.Button("ํ…Œ์ŠคํŠธ ์‹œ์ž‘ํ•˜๊ธฐ", variant="primary", size="lg")
# ์งˆ๋ฌธ ์„น์…˜
with gr.Group(visible=False) as question_section:
question_text = gr.Markdown("## ์งˆ๋ฌธ")
answer_radio = gr.Radio(
choices=["A", "B"],
label="์„ ํƒํ•ด์ฃผ์„ธ์š”",
value=None
)
with gr.Row():
prev_button = gr.Button("์ด์ „ ์งˆ๋ฌธ", visible=False)
next_button = gr.Button("๋‹ค์Œ ์งˆ๋ฌธ", variant="primary")
progress_bar = gr.Slider(
minimum=0,
maximum=len(questions),
value=1,
step=1,
label="์ง„ํ–‰ ์ƒํ™ฉ",
interactive=False
)
# ๊ฒฐ๊ณผ ์„น์…˜
with gr.Group(visible=False) as result_section:
result_title = gr.Markdown("## ๋‹น์‹ ์˜ MBTI ๊ฒฐ๊ณผ")
result_content = gr.HTML()
restart_button = gr.Button("๋‹ค์‹œ ํ…Œ์ŠคํŠธํ•˜๊ธฐ", variant="secondary")
# ํ•จ์ˆ˜ ์ •์˜
def start_test():
current_q = questions[0]
q_text = f"## {current_q['question']}"
return {
"current_question": 0,
"scores": {"EI": 0, "SN": 0, "TF": 0, "JP": 0},
"completed": False
}, gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), q_text, gr.update(choices=current_q["options"], value=None), 1, gr.update(visible=False)
def update_question(direction, state):
new_index = state["current_question"] + direction
if 0 <= new_index < len(questions):
state["current_question"] = new_index
current_q = questions[new_index]
q_text = f"## {current_q['question']}"
is_first = new_index == 0
is_last = new_index == len(questions) - 1
return state, q_text, gr.update(choices=current_q["options"], value=None), new_index + 1, gr.update(visible=not is_first)
return state, "", gr.update(), state["current_question"] + 1, gr.update()
def next_question(choice, state):
if choice is None:
current_q = questions[state["current_question"]]
return state, f"## {current_q['question']}", gr.update(), gr.update(), gr.update()
# ํ˜„์žฌ ์งˆ๋ฌธ๊ณผ ๊ทธ์— ๋Œ€ํ•œ ๋‹ต๋ณ€ ์ฒ˜๋ฆฌ
current_q = questions[state["current_question"]]
scale = current_q["scale"]
# ์ ์ˆ˜ ์—…๋ฐ์ดํŠธ
if choice == current_q["options"][0]: # A ์„ ํƒ
if scale == "EI":
state["scores"]["EI"] += 1
elif scale == "SN":
state["scores"]["SN"] += 1
elif scale == "TF":
state["scores"]["TF"] += 1
elif scale == "JP":
state["scores"]["JP"] += 1
else: # B ์„ ํƒ
if scale == "EI":
state["scores"]["EI"] -= 1
elif scale == "SN":
state["scores"]["SN"] -= 1
elif scale == "TF":
state["scores"]["TF"] -= 1
elif scale == "JP":
state["scores"]["JP"] -= 1
# ๋‹ค์Œ ์งˆ๋ฌธ ๋˜๋Š” ๊ฒฐ๊ณผ๋กœ ์ด๋™
next_index = state["current_question"] + 1
if next_index >= len(questions):
# ๋งˆ์ง€๋ง‰ ์งˆ๋ฌธ์ด๋ฉด ๊ฒฐ๊ณผ ํ‘œ์‹œ
state["completed"] = True
mbti_result = calculate_mbti(state["scores"])
description = mbti_descriptions[mbti_result]
result_html = f"""
<div style="text-align: center; padding: 20px; background-color: #f5f5f5; border-radius: 10px; margin-bottom: 20px;">
<h2 style="color: #333; margin-bottom: 10px;">{description["title"]}</h2>
<p style="font-size: 18px; margin-bottom: 20px;">{description["description"]}</p>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px;">
<div style="background-color: #e6f7ff; padding: 15px; border-radius: 8px;">
<h3 style="color: #0066cc; margin-bottom: 10px;">๊ฐ•์ </h3>
<p>{description["strengths"]}</p>
</div>
<div style="background-color: #fff0f0; padding: 15px; border-radius: 8px;">
<h3 style="color: #cc0000; margin-bottom: 10px;">์•ฝ์ </h3>
<p>{description["weaknesses"]}</p>
</div>
</div>
<div style="background-color: #f0f8ff; padding: 15px; border-radius: 8px; margin-bottom: 20px;">
<h3 style="color: #003366; margin-bottom: 10px;">๋Œ€์ธ๊ด€๊ณ„ ์„ฑํ–ฅ</h3>
<p>{description["relationships"]}</p>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<div style="background-color: #f5f5dc; padding: 15px; border-radius: 8px;">
<h3 style="color: #8b4513; margin-bottom: 10px;">๋Œ€ํ‘œ ์ธ๋ฌผ</h3>
<p>{description["famous"]}</p>
</div>
<div style="background-color: #f0fff0; padding: 15px; border-radius: 8px;">
<h3 style="color: #006400; margin-bottom: 10px;">์ ํ•ฉํ•œ ์ง์—…</h3>
<p>{description["careers"]}</p>
</div>
</div>
<div style="text-align: center; margin-top: 30px; padding: 15px; background-color: #fffaf0; border-radius: 8px;">
<p style="font-style: italic; color: #666;">โ€ป ์ด ๊ฒฐ๊ณผ๋Š” ๊ฐ„๋‹จํ•œ ์งˆ๋ฌธ์„ ํ†ตํ•œ ์ฐธ๊ณ ์šฉ์ด๋ฉฐ, ์ „๋ฌธ์ ์ธ MBTI ๊ฒ€์‚ฌ๋Š” ๊ณต์ธ๋œ ๊ธฐ๊ด€์„ ํ†ตํ•ด ๋ฐ›์œผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.</p>
</div>
"""
return state, gr.update(visible=False), gr.update(visible=True), f"## ๋‹น์‹ ์˜ MBTI ์œ ํ˜•์€: {mbti_result}", result_html, gr.update()
# ๋‹ค์Œ ์งˆ๋ฌธ์œผ๋กœ ์ด๋™
state["current_question"] = next_index
next_q = questions[next_index]
return state, f"## {next_q['question']}", gr.update(choices=next_q["options"], value=None), next_index + 1, gr.update(visible=True), gr.update()
def restart():
return {
"current_question": 0,
"scores": {"EI": 0, "SN": 0, "TF": 0, "JP": 0},
"completed": False
}, gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), "## " + questions[0]["question"], gr.update(choices=questions[0]["options"], value=None), 1, gr.update(visible=False)
# ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ
start_button.click(
fn=start_test,
outputs=[state, intro, question_section, result_section, question_text, answer_radio, progress_bar, prev_button]
)
next_button.click(
fn=next_question,
inputs=[answer_radio, state],
outputs=[state, question_text, answer_radio, progress_bar, prev_button, result_section]
)
prev_button.click(
fn=lambda state: update_question(-1, state),
inputs=[state],
outputs=[state, question_text, answer_radio, progress_bar, prev_button]
)
restart_button.click(
fn=restart,
outputs=[state, intro, question_section, start_button, result_section, question_text, answer_radio, progress_bar, prev_button]
)
# ๋งˆ์ง€๋ง‰ ์งˆ๋ฌธ์—์„œ ๋‹ค์Œ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ๊ฒฐ๊ณผ ํ‘œ์‹œ
def show_result(choice, state):
if choice is None:
current_q = questions[state["current_question"]]
return state, f"## {current_q['question']}", gr.update(), gr.update(), gr.update()
# ํ˜„์žฌ ์งˆ๋ฌธ๊ณผ ๊ทธ์— ๋Œ€ํ•œ ๋‹ต๋ณ€ ์ฒ˜๋ฆฌ
current_q = questions[state["current_question"]]
scale = current_q["scale"]
# ์ ์ˆ˜ ์—…๋ฐ์ดํŠธ
if choice == current_q["options"][0]: # A ์„ ํƒ
if scale == "EI":
state["scores"]["EI"] += 1
elif scale == "SN":
state["scores"]["SN"] += 1
elif scale == "TF":
state["scores"]["TF"] += 1
elif scale == "JP":
state["scores"]["JP"] += 1
else: # B ์„ ํƒ
if scale == "EI":
state["scores"]["EI"] -= 1
elif scale == "SN":
state["scores"]["SN"] -= 1
elif scale == "TF":
state["scores"]["TF"] -= 1
elif scale == "JP":
state["scores"]["JP"] -= 1
# ๋‹ค์Œ ์งˆ๋ฌธ ๋˜๋Š” ๊ฒฐ๊ณผ๋กœ ์ด๋™
next_index = state["current_question"] + 1
if next_index >= len(questions):
# ๋งˆ์ง€๋ง‰ ์งˆ๋ฌธ์ด๋ฉด ๊ฒฐ๊ณผ ํ‘œ์‹œ
state["completed"] = True
mbti_result = calculate_mbti(state["scores"])
description = mbti_descriptions[mbti_result]
result_html = f"""
<div style="text-align: center; padding: 20px; background-color: #f5f5f5; border-radius: 10px; margin-bottom: 20px;">
<h2 style="color: #333; margin-bottom: 10px;">{description["title"]}</h2>
<p style="font-size: 18px; margin-bottom: 20px;">{description["description"]}</p>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px;">
<div style="background-color: #e6f7ff; padding: 15px; border-radius: 8px;">
<h3 style="color: #0066cc; margin-bottom: 10px;">๊ฐ•์ </h3>
<p>{description["strengths"]}</p>
</div>
<div style="background-color: #fff0f0; padding: 15px; border-radius: 8px;">
<h3 style="color: #cc0000; margin-bottom: 10px;">์•ฝ์ </h3>
<p>{description["weaknesses"]}</p>
</div>
</div>
<div style="background-color: #f0f8ff; padding: 15px; border-radius: 8px; margin-bottom: 20px;">
<h3 style="color: #003366; margin-bottom: 10px;">๋Œ€์ธ๊ด€๊ณ„ ์„ฑํ–ฅ</h3>
<p>{description["relationships"]}</p>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<div style="background-color: #f5f5dc; padding: 15px; border-radius: 8px;">
<h3 style="color: #8b4513; margin-bottom: 10px;">๋Œ€ํ‘œ ์ธ๋ฌผ</h3>
<p>{description["famous"]}</p>
</div>
<div style="background-color: #f0fff0; padding: 15px; border-radius: 8px;">
<h3 style="color: #006400; margin-bottom: 10px;">์ ํ•ฉํ•œ ์ง์—…</h3>
<p>{description["careers"]}</p>
</div>
</div>
<div style="text-align: center; margin-top: 30px; padding: 15px; background-color: #fffaf0; border-radius: 8px;">
<p style="font-style: italic; color: #666;">โ€ป ์ด ๊ฒฐ๊ณผ๋Š” ๊ฐ„๋‹จํ•œ ์งˆ๋ฌธ์„ ํ†ตํ•œ ์ฐธ๊ณ ์šฉ์ด๋ฉฐ, ์ „๋ฌธ์ ์ธ MBTI ๊ฒ€์‚ฌ๋Š” ๊ณต์ธ๋œ ๊ธฐ๊ด€์„ ํ†ตํ•ด ๋ฐ›์œผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.</p>
</div>
"""
return state, gr.update(visible=False), gr.update(visible=True), f"## ๋‹น์‹ ์˜ MBTI ์œ ํ˜•์€: {mbti_result}", result_html
# ๋‹ค์Œ ์งˆ๋ฌธ์œผ๋กœ ์ด๋™
state["current_question"] = next_index
next_q = questions[next_index]
return state, gr.update(), gr.update(), gr.update(), gr.update()
next_button.click(
fn=show_result,
inputs=[answer_radio, state],
outputs=[state, question_section, result_section, result_title, result_content]
)
app.launch()
if __name__ == '__main__':
demo.launch()