Spaces:
Runtime error
Runtime error
News Text with a URL Link
#4
by
gabrielyang
- opened
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()
|