Blocks UI 및 폰트 굵게 적용
Browse files
app.py
CHANGED
|
@@ -1,14 +1,10 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
from news_analyzer import run_once, title_attention_index
|
| 4 |
import math
|
| 5 |
|
| 6 |
-
|
| 7 |
def convert_sim_to_text(score: float, threshold: float = 0.5) -> str:
|
| 8 |
-
|
| 9 |
-
유사도 점수를 기준으로 텍스트 등급을 반환합니다.
|
| 10 |
-
threshold (기본값 0.5) 이상이면 '유사', 미만이면 '유사하지 않음'으로 판단합니다.
|
| 11 |
-
"""
|
| 12 |
if score is None or (isinstance(score, float) and math.isnan(score)):
|
| 13 |
return "판단 불가" # nan 값 처리
|
| 14 |
|
|
@@ -25,11 +21,10 @@ def predict(title, body):
|
|
| 25 |
final_score = r["최종 기사 점수"]
|
| 26 |
grade = title_attention_index(final_score)
|
| 27 |
|
| 28 |
-
# [NEW] 텍스트 변환 로직을 predict 함수에 직접 추가
|
| 29 |
summary_sim_text = convert_sim_to_text(r["요약유사도"], threshold=0.45)
|
| 30 |
body_sim_text = convert_sim_to_text(r["본문 일치도(Top5 평균)"], threshold=0.5)
|
| 31 |
|
| 32 |
-
#
|
| 33 |
return (
|
| 34 |
grade, # [0] -> output_grade
|
| 35 |
summary_sim_text, # [1] -> output_summary_sim
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from news_analyzer import run_once, title_attention_index
|
| 3 |
import math
|
| 4 |
|
| 5 |
+
|
| 6 |
def convert_sim_to_text(score: float, threshold: float = 0.5) -> str:
|
| 7 |
+
|
|
|
|
|
|
|
|
|
|
| 8 |
if score is None or (isinstance(score, float) and math.isnan(score)):
|
| 9 |
return "판단 불가" # nan 값 처리
|
| 10 |
|
|
|
|
| 21 |
final_score = r["최종 기사 점수"]
|
| 22 |
grade = title_attention_index(final_score)
|
| 23 |
|
|
|
|
| 24 |
summary_sim_text = convert_sim_to_text(r["요약유사도"], threshold=0.45)
|
| 25 |
body_sim_text = convert_sim_to_text(r["본문 일치도(Top5 평균)"], threshold=0.5)
|
| 26 |
|
| 27 |
+
#
|
| 28 |
return (
|
| 29 |
grade, # [0] -> output_grade
|
| 30 |
summary_sim_text, # [1] -> output_summary_sim
|