Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,48 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
def mbti_analysis(answers):
|
5 |
-
# 각 성격 지표에 대한 점수 계산
|
6 |
-
extroversion = sum(answers[:5])
|
7 |
-
introversion = sum(answers[5:10])
|
8 |
-
sensing = sum(answers[10:15])
|
9 |
-
intuition = sum(answers[15:20])
|
10 |
-
|
11 |
-
# 각 성향에 대한 퍼센트 계산
|
12 |
-
e_percentage = (extroversion / (extroversion + introversion)) * 100
|
13 |
-
i_percentage = 100 - e_percentage
|
14 |
-
s_percentage = (sensing / (sensing + intuition)) * 100
|
15 |
-
n_percentage = 100 - s_percentage
|
16 |
-
|
17 |
-
# 성향 결정
|
18 |
-
if e_percentage > i_percentage:
|
19 |
-
e_or_i = "E"
|
20 |
-
else:
|
21 |
-
e_or_i = "I"
|
22 |
-
|
23 |
-
if s_percentage > n_percentage:
|
24 |
-
s_or_n = "S"
|
25 |
-
else:
|
26 |
-
s_or_n = "N"
|
27 |
-
|
28 |
-
# 성격 유형 결과 출력
|
29 |
-
return f"외향형: {e_percentage:.2f}%, 내향형: {i_percentage:.2f}%\n감각형: {s_percentage:.2f}%, 직관형: {n_percentage:.2f}%"
|
30 |
-
|
31 |
-
# Gradio 인터페이스 구성
|
32 |
questions = [
|
33 |
-
"
|
34 |
-
"
|
35 |
-
|
|
|
|
|
36 |
]
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
inputs=
|
43 |
-
outputs="text",
|
44 |
-
|
45 |
-
description="MBTI 성격 유형을 분석하여 결과를 퍼센트로 보여줍니다."
|
46 |
-
)
|
47 |
|
48 |
-
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# 질문 설정 (20개 이상)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
questions = [
|
5 |
+
"나는 다른 사람들과 함께 있을 때 에너지를 얻는다.",
|
6 |
+
"나는 주로 큰 그림을 보는 것을 선호한다.",
|
7 |
+
"나는 결정을 내릴 때 논리와 사실에 기반한다.",
|
8 |
+
"나는 미리 계획을 세우는 것을 좋아한다.",
|
9 |
+
# 더 많은 질문들을 여기에 추가합니다...
|
10 |
]
|
11 |
|
12 |
+
# 결과 계산 로직
|
13 |
+
def calculate_mbti(responses):
|
14 |
+
e_score = sum([responses[i] for i in [0]]) # E/I 관련 질문들에 대한 점수 합산
|
15 |
+
i_score = sum([responses[i] for i in [1]])
|
16 |
+
# 동일한 방식으로 다른 차원(N/S, T/F, J/P)에 대한 점수 계산
|
17 |
+
|
18 |
+
mbti_type = ""
|
19 |
+
mbti_type += "E" if e_score > i_score else "I"
|
20 |
+
# 다른 차원에 대한 계산 추가
|
21 |
+
|
22 |
+
return mbti_type
|
23 |
|
24 |
+
# Gradio 인터페이스
|
25 |
+
def create_interface():
|
26 |
+
inputs = [gr.Radio(choices=["매우 아니다", "아니다", "보통이다", "그렇다", "매우 그렇다"], label=questions[i]) for i in range(len(questions))]
|
27 |
+
interface = gr.Interface(fn=calculate_mbti, inputs=inputs, outputs="text", title="MBTI 분석기", description="20개 이상의 질문에 답하고 당신의 MBTI 유형을 확인하세요!")
|
28 |
+
return interface
|
|
|
|
|
29 |
|
30 |
+
# 인터페이스 실행
|
31 |
+
interface = create_interface()
|
32 |
+
interface.launch()
|