DSJA commited on
Commit
bf95555
·
1 Parent(s): 85f6cb6

UI 텍스트 수정 (숫자 -> 단어)

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,7 +1,7 @@
1
  # app.py
2
  import gradio as gr
3
  from news_analyzer import run_once, title_attention_index
4
- import math # math 모듈 추가
5
 
6
  # [NEW] ✨ 점수를 텍스트로 변환하는 헬퍼 함수
7
  # (news_analyzer.py에 있던 함수를 app.py로 가져옵니다)
@@ -13,7 +13,7 @@ def convert_sim_to_text(score: float, threshold: float = 0.5) -> str:
13
  if score is None or (isinstance(score, float) and math.isnan(score)):
14
  return "판단 불가" # nan 값 처리
15
 
16
- if score >= threshold + 0.15: # 예: 0.65 이상
17
  return "높음 (제목이 본문을 잘 반영합니다)"
18
  elif score >= threshold: # 예: 0.5 ~ 0.65
19
  return "보통 (제목이 본문과 어느 정도 일치합니다)"
@@ -30,14 +30,12 @@ def predict(title, body):
30
  summary_sim_text = convert_sim_to_text(r["요약유사도"], threshold=0.45)
31
  body_sim_text = convert_sim_to_text(r["본문 일치도(Top5 평균)"], threshold=0.5)
32
 
33
- # [MODIFIED] 💡 return 순서 변경
34
- # 'grade' (제목 주의 지수)를 가장 첫 번째로 보냅니다.
35
  return (
36
- grade, # <-- [0]
37
- summary_sim_text, # <-- [1]
38
- body_sim_text, # <-- [2]
39
- r["과장점수"], # <-- [3]
40
- final_score, # <-- [4]
41
  )
42
 
43
  demo = gr.Interface(
@@ -50,10 +48,10 @@ demo = gr.Interface(
50
  # '제목 주의 지수'를 가장 위로 올리고, 텍스트 출력을 위해 Textbox로 변경
51
  outputs=[
52
  gr.Textbox(label="제목 주의 지수", interactive=False), # <-- [0]
53
- gr.Textbox(label="요약유사도"), # <-- [1]
54
- gr.Textbox(label="본문 일치도(Top5 평균)"), # <-- [2]
55
- gr.Number(label="과장점수"), # <-- [3]
56
- gr.Number(label="최종 기사 점수"), # <-- [4]
57
  ],
58
  title="제목 주의 지수",
59
  description=(
 
1
  # app.py
2
  import gradio as gr
3
  from news_analyzer import run_once, title_attention_index
4
+ import math
5
 
6
  # [NEW] ✨ 점수를 텍스트로 변환하는 헬퍼 함수
7
  # (news_analyzer.py에 있던 함수를 app.py로 가져옵니다)
 
13
  if score is None or (isinstance(score, float) and math.isnan(score)):
14
  return "판단 불가" # nan 값 처리
15
 
16
+ if score >= threshold + 0.20: # 0.7 이상
17
  return "높음 (제목이 본문을 잘 반영합니다)"
18
  elif score >= threshold: # 예: 0.5 ~ 0.65
19
  return "보통 (제목이 본문과 어느 정도 일치합니다)"
 
30
  summary_sim_text = convert_sim_to_text(r["요약유사도"], threshold=0.45)
31
  body_sim_text = convert_sim_to_text(r["본문 일치도(Top5 평균)"], threshold=0.5)
32
 
 
 
33
  return (
34
+ grade,
35
+ final_score,
36
+ summary_sim_text,
37
+ body_sim_text,
38
+ r["과장점수"],
39
  )
40
 
41
  demo = gr.Interface(
 
48
  # '제목 주의 지수'를 가장 위로 올리고, 텍스트 출력을 위해 Textbox로 변경
49
  outputs=[
50
  gr.Textbox(label="제목 주의 지수", interactive=False), # <-- [0]
51
+ gr.Textbox(label="요약 유사도\n기사 제목과 기사의 요약된 내용이 일치할까?"), # <-- [1]
52
+ gr.Textbox(label="본문 일치도(Top5 평균)\n기사 내용을 잘 함축한 제목일까?"), # <-- [2]
53
+ gr.Number(label="과장점수\n기사의 제목이 얼마나 과장되어 있을까?"), # <-- [3]
54
+ gr.Number(label="최종 기사 점수(\n이 기사를 점수 매겨본다면?"), # <-- [4]
55
  ],
56
  title="제목 주의 지수",
57
  description=(