Spaces:
Runtime error
Runtime error
| # -*- coding: utf-8 -*- | |
| """Untitled0.ipynb | |
| Automatically generated by Colab. | |
| Original file is located at | |
| https://colab.research.google.com/drive/1wnyeCNxzRVxoae3tCcMuf3s9Adx503U7 | |
| """ | |
| # app.py | |
| import gradio as gr | |
| from news_analyzer import run_once, title_attention_index | |
| def predict(title, body): | |
| r = run_once(title, body) | |
| final_score = r["최종 기사 점수"] | |
| grade = title_attention_index(final_score) | |
| return ( | |
| r["요약유사도"], | |
| r["본문 일치도(Top5 평균)"], | |
| r["과장점수"], | |
| final_score, | |
| grade, | |
| ) | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=[ | |
| gr.Textbox(label="제목", lines=2), | |
| gr.Textbox(label="본문", lines=18, placeholder="여기에 기사 본문을 붙여넣으세요"), | |
| ], | |
| outputs=[ | |
| gr.Number(label="요약유사도"), | |
| gr.Number(label="본문 일치도(Top5 평균)"), | |
| gr.Number(label="과장점수"), | |
| gr.Number(label="최종 기사 점수"), | |
| gr.Textbox(label="제목 주의 지수", interactive=False), | |
| ], | |
| title="제목 주의 지수", | |
| description=( | |
| "제목/본문을 입력하면 제목-본문 유사도, 과장 점수를 바탕으로 '제목 주의 지수'를 계산합니다.\n\n" | |
| "ℹ️ **자세한 설명이 궁금하다면 " | |
| "[여기를 클릭하세요](https://www.notion.so/25cb058cee088026badfcab340e9966d?source=copy_link)**" | |
| ), | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() # Spaces에서는 이 라인이 없어도 자동 실행됩니다. |