springwater commited on
Commit
19cd81e
Β·
verified Β·
1 Parent(s): 8cb5626

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -7
app.py CHANGED
@@ -28,12 +28,34 @@ options = [
28
  ["리더십을 λ°œνœ˜ν•œλ‹€", "νŒ€μ›μœΌλ‘œμ„œ μ§€μ›ν•œλ‹€"]
29
  ]
30
 
31
- # MBTI μœ ν˜• 계산 ν•¨μˆ˜
32
  def calculate_mbti(*answers):
33
- # λ‹¨μˆœν™”λœ μ˜ˆμ‹œ 둜직: μ„ νƒλœ μ˜΅μ…˜μ˜ 인덱슀λ₯Ό 기반으둜 MBTI μœ ν˜• κ²°μ •
34
- mbti_type = "INFP" # μ˜ˆμ‹œ κ²°κ³Ό
35
- mbti_interpretation = "당신은 이상적이고, 열정적이며, 창의적인 μ‚¬λžŒμž…λ‹ˆλ‹€." # μ˜ˆμ‹œ 해석
36
- return mbti_type, mbti_interpretation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ꡬ성
39
  iface = gr.Interface(
@@ -41,10 +63,11 @@ iface = gr.Interface(
41
  inputs=[gr.Radio(options[i], label=questions[i]) for i in range(10)],
42
  outputs=[
43
  gr.Textbox(label="λ‹Ήμ‹ μ˜ MBTI μœ ν˜•"),
44
- gr.Textbox(label="μœ ν˜• 해석")
 
45
  ],
46
  title="MBTI 진단 ν…ŒμŠ€νŠΈ",
47
- description="10개의 μ§ˆλ¬Έμ— λ‹΅ν•˜μ—¬ λ‹Ήμ‹ μ˜ MBTI μœ ν˜•μ„ μ•Œμ•„λ³΄μ„Έμš”."
48
  )
49
 
50
  # μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰
 
28
  ["리더십을 λ°œνœ˜ν•œλ‹€", "νŒ€μ›μœΌλ‘œμ„œ μ§€μ›ν•œλ‹€"]
29
  ]
30
 
31
+ # MBTI μœ ν˜• 계산 및 정보 λ°˜ν™˜ ν•¨μˆ˜
32
  def calculate_mbti(*answers):
33
+ # MBTI 차원 점수 μ΄ˆκΈ°ν™”
34
+ dimensions = {"E": 0, "I": 0, "S": 0, "N": 0, "T": 0, "F": 0, "J": 0, "P": 0}
35
+
36
+ # μ‚¬μš©μžμ˜ 선택에 따라 차원 점수 μ—…λ°μ΄νŠΈ
37
+ for answer, (introvert, extrovert) in zip(answers, [(1, 0), (0, 1), (1, 0), (0, 1), (1, 0), (0, 1), (0, 1), (0, 1), (1, 0), (1, 0)]):
38
+ if answer == 0: # 첫 번째 μ˜΅μ…˜ 선택
39
+ dimensions["E"] += extrovert
40
+ dimensions["I"] += introvert
41
+ else: # 두 번째 μ˜΅μ…˜ 선택
42
+ dimensions["S"] += extrovert
43
+ dimensions["N"] += introvert
44
+ dimensions["T"] += extrovert
45
+ dimensions["F"] += introvert
46
+ dimensions["J"] += extrovert
47
+ dimensions["P"] += introvert
48
+
49
+ # MBTI μœ ν˜• κ²°μ •
50
+ mbti_type = ""
51
+ mbti_type += "E" if dimensions["E"] >= dimensions["I"] else "I"
52
+ mbti_type += "S" if dimensions["S"] >= dimensions["N"] else "N"
53
+ mbti_type += "T" if dimensions["T"] >= dimensions["F"] else "F"
54
+ mbti_type += "J" if dimensions["J"] >= dimensions["P"] else "P"
55
+
56
+ # MBTI μœ ν˜•μ— λ”°λ₯Έ μ„±κ²©μ˜ μž₯단점과 유λͺ…인 λ°˜ν™˜
57
+ mbti_details = mbti_info.get(mbti_type, {"μž₯단점": "정보 μ—†μŒ", "유λͺ…인": "정보 μ—†μŒ"})
58
+ return mbti_type, mbti_details["μž₯단점"], mbti_details["유λͺ…인"]
59
 
60
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ꡬ성
61
  iface = gr.Interface(
 
63
  inputs=[gr.Radio(options[i], label=questions[i]) for i in range(10)],
64
  outputs=[
65
  gr.Textbox(label="λ‹Ήμ‹ μ˜ MBTI μœ ν˜•"),
66
+ gr.Textbox(label="μœ ν˜•μ˜ μž₯단점"),
67
+ gr.Textbox(label="λŒ€ν‘œμ μΈ 유λͺ…인")
68
  ],
69
  title="MBTI 진단 ν…ŒμŠ€νŠΈ",
70
+ description="10개의 μ§ˆλ¬Έμ— λ‹΅ν•˜μ—¬ λ‹Ήμ‹ μ˜ MBTI μœ ν˜•κ³Ό κ·Έ μœ ν˜•μ˜ μž₯단점, λŒ€ν‘œμ μΈ 유λͺ…인을 μ•Œμ•„λ³΄μ„Έμš”."
71
  )
72
 
73
  # μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰