seawolf2357 commited on
Commit
24eb1e0
Β·
verified Β·
1 Parent(s): c560726

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -1,27 +1,32 @@
1
  import gradio as gr
2
 
3
- # μ‚¬μš©μžμ˜ 응닡을 λΆ„μ„ν•˜μ—¬ MBTI μœ ν˜•μ„ κ³„μ‚°ν•˜λŠ” ν•¨μˆ˜
4
  def mbti_diagnosis(*answers):
5
  dimension_scores = {'E': 0, 'I': 0, 'N': 0, 'S': 0, 'T': 0, 'F': 0, 'J': 0, 'P': 0}
6
- dimensions = ['E', 'I', 'N', 'S', 'T', 'F', 'J', 'P']
7
 
8
- # 각 문항에 따라 차원 점수λ₯Ό μ—…λ°μ΄νŠΈ
9
  for i, answer in enumerate(answers):
10
- # '예' 응닡은 1둜, 'μ•„λ‹ˆμ˜€' 응닡은 0으둜 계산
11
  score = 1 if answer == "예" else 0
12
- if i % 4 == 0 or i % 4 == 1:
13
- dimension_scores[dimensions[i % 8]] += score
14
- else:
15
- dimension_scores[dimensions[i % 8 + 1]] += score
16
-
 
 
 
 
 
 
17
  # MBTI μœ ν˜• κ²°μ •
18
  mbti_type = ''
19
- mbti_type += 'E' if dimension_scores['E'] >= dimension_scores['I'] else 'I'
20
- mbti_type += 'N' if dimension_scores['N'] >= dimension_scores['S'] else 'S'
21
- mbti_type += 'T' if dimension_scores['T'] >= dimension_scores['F'] else 'F'
22
- mbti_type += 'J' if dimension_scores['J'] >= dimension_scores['P'] else 'P'
23
 
24
  return mbti_type
 
 
25
  questions = [
26
  "μ‚¬λžŒλ“€κ³Ό μ–΄μšΈλ¦¬λŠ” 것을 μ’‹μ•„ν•˜λ‚˜μš”?",
27
  "ꡬ체적인 μ‚¬μ‹€λ³΄λ‹€λŠ” 아이디어에 더 관심이 λ§Žλ‚˜μš”?",
 
1
  import gradio as gr
2
 
 
3
  def mbti_diagnosis(*answers):
4
  dimension_scores = {'E': 0, 'I': 0, 'N': 0, 'S': 0, 'T': 0, 'F': 0, 'J': 0, 'P': 0}
 
5
 
6
+ # 각 문항에 따라 차원 점수λ₯Ό μ—…λ°μ΄νŠΈ (λ³΄μ •λœ 둜직)
7
  for i, answer in enumerate(answers):
 
8
  score = 1 if answer == "예" else 0
9
+ if i in [0, 1, 4, 5, 8, 9, 12, 13, 16, 17]: # E, N, T, J 차원에 ν•΄λ‹Ήν•˜λŠ” λ¬Έν•­ 인덱슀
10
+ if i % 2 == 0: # E, N
11
+ dimension_scores['E' if i < 8 else 'N'] += score
12
+ else: # I, S
13
+ dimension_scores['I' if i < 8 else 'S'] += score
14
+ else: # T, F, J, P 차원에 ν•΄λ‹Ήν•˜λŠ” λ¬Έν•­ 인덱슀
15
+ if i % 2 == 0: # T, J
16
+ dimension_scores['T' if i < 16 else 'J'] += score
17
+ else: # F, P
18
+ dimension_scores['F' if i < 16 else 'P'] += score
19
+
20
  # MBTI μœ ν˜• κ²°μ •
21
  mbti_type = ''
22
+ mbti_type += 'E' if dimension_scores['E'] > dimension_scores['I'] else 'I'
23
+ mbti_type += 'N' if dimension_scores['N'] > dimension_scores['S'] else 'S'
24
+ mbti_type += 'T' if dimension_scores['T'] > dimension_scores['F'] else 'F'
25
+ mbti_type += 'J' if dimension_scores['J'] > dimension_scores['P'] else 'P'
26
 
27
  return mbti_type
28
+
29
+
30
  questions = [
31
  "μ‚¬λžŒλ“€κ³Ό μ–΄μšΈλ¦¬λŠ” 것을 μ’‹μ•„ν•˜λ‚˜μš”?",
32
  "ꡬ체적인 μ‚¬μ‹€λ³΄λ‹€λŠ” 아이디어에 더 관심이 λ§Žλ‚˜μš”?",