gabrielwithhappy commited on
Commit
7ce7d86
โ€ข
1 Parent(s): 39fc926

update examples with new links

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -36,7 +36,7 @@ config.request_timeout = 10
36
 
37
  class news_collector:
38
  def __init__(self):
39
- self.examples = []
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
- for news_url in news_links:
 
63
  article = self.get_new_parser(news_url)
64
- self.examples.append(get_summary(article.text[:1000]))
 
 
65
 
66
  def collect_news():
67
  news = news_collector()
68
  news.update_news_examples()
69
- return news.examples
 
 
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 = gr.Textbox( placeholder="๋‰ด์Šค ๊ธฐ์‚ฌ ๋‚ด์šฉ์„ ์ž…๋ ฅํ•˜์„ธ์š”." ),
99
- examples=examples)
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()