Spaces:
Runtime error
Runtime error
gabrielwithhappy
commited on
Commit
•
7ce7d86
1
Parent(s):
39fc926
update examples with new links
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ config.request_timeout = 10
|
|
36 |
|
37 |
class news_collector:
|
38 |
def __init__(self):
|
39 |
-
self.
|
40 |
|
41 |
def get_new_parser(self, url):
|
42 |
article = Article(url, language='ko')
|
@@ -59,16 +59,20 @@ class news_collector:
|
|
59 |
|
60 |
def update_news_examples(self):
|
61 |
news_links = self.get_news_links()
|
62 |
-
|
|
|
63 |
article = self.get_new_parser(news_url)
|
64 |
-
self.
|
|
|
|
|
65 |
|
66 |
def collect_news():
|
67 |
news = news_collector()
|
68 |
news.update_news_examples()
|
69 |
-
return news.
|
|
|
|
|
70 |
|
71 |
-
examples = collect_news()
|
72 |
|
73 |
title = "균형잡힌 뉴스 읽기 (Balanced News Reading)"
|
74 |
|
@@ -94,10 +98,15 @@ with gr.Blocks() as demo:
|
|
94 |
""")
|
95 |
|
96 |
with gr.Tab("데모"):
|
|
|
97 |
gr.load("models/gabrielyang/finance_news_classifier-KR_v7",
|
98 |
-
inputs =
|
99 |
-
|
100 |
|
|
|
|
|
|
|
|
|
101 |
|
102 |
if __name__ == "__main__":
|
103 |
demo.launch()
|
|
|
36 |
|
37 |
class news_collector:
|
38 |
def __init__(self):
|
39 |
+
self.examples_text = []
|
40 |
|
41 |
def get_new_parser(self, url):
|
42 |
article = Article(url, language='ko')
|
|
|
59 |
|
60 |
def update_news_examples(self):
|
61 |
news_links = self.get_news_links()
|
62 |
+
# TODO roll back
|
63 |
+
for news_url in news_links[:2]:
|
64 |
article = self.get_new_parser(news_url)
|
65 |
+
self.examples_text.append([get_summary(article.text[:1000]), news_url])
|
66 |
+
|
67 |
+
|
68 |
|
69 |
def collect_news():
|
70 |
news = news_collector()
|
71 |
news.update_news_examples()
|
72 |
+
return news.examples_text
|
73 |
+
|
74 |
+
|
75 |
|
|
|
76 |
|
77 |
title = "균형잡힌 뉴스 읽기 (Balanced News Reading)"
|
78 |
|
|
|
98 |
""")
|
99 |
|
100 |
with gr.Tab("데모"):
|
101 |
+
Link_TXT = gr.Textbox(label="뉴스 내용", placeholder = "뉴스 기사 내용을 입력하세요.")
|
102 |
gr.load("models/gabrielyang/finance_news_classifier-KR_v7",
|
103 |
+
inputs = Link_TXT)
|
104 |
+
Link_URL = gr.Textbox(label="뉴스 URL")
|
105 |
|
106 |
+
gr.Examples(
|
107 |
+
collect_news(),
|
108 |
+
[Link_TXT, Link_URL],
|
109 |
+
)
|
110 |
|
111 |
if __name__ == "__main__":
|
112 |
demo.launch()
|