gabrielwithhappy commited on
Commit
d47bebc
โ€ข
1 Parent(s): bca29d2

fix null example issue

Browse files
Files changed (1) hide show
  1. app.py +8 -15
app.py CHANGED
@@ -44,6 +44,7 @@ class news_collector:
44
  def __init__(self):
45
  self.examples_text = []
46
 
 
47
  def get_new_parser(self, url):
48
  article = Article(url, language='ko')
49
  article.download()
@@ -72,23 +73,14 @@ class news_collector:
72
  self.examples_text.append([get_summary(article.text[:1500]), news_url])
73
 
74
 
75
-
76
- news_data = []
77
-
78
- def update_news_data():
79
- global news_data
80
- news_data = news_collector().update_news_examples()
81
- print("๋‰ด์Šค ๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ ์™„๋ฃŒ")
82
-
83
- update_news_data()
84
-
85
  title = "๊ท ํ˜•์žกํžŒ ๋‰ด์Šค ์ฝ๊ธฐ (Balanced News Reading)"
86
 
87
 
88
 
89
  with gr.Blocks(theme='pseudolab/huggingface-korea-theme') as demo:
90
- # news = news_collector()
91
- # news.update_news_examples()
 
92
 
93
  with gr.Tab("์†Œ๊ฐœ"):
94
  gr.Markdown(
@@ -112,11 +104,12 @@ with gr.Blocks(theme='pseudolab/huggingface-korea-theme') as demo:
112
  inputs = Link_TXT)
113
  Link_URL = gr.Textbox(label="๋‰ด์Šค URL")
114
 
115
- update_button = gr.Button(value="๋‰ด์Šค ๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ")
116
- update_button.click(fn=update_news_data, inputs=None, outputs=None)
 
117
 
118
  gr.Examples(
119
- news_data,
120
  [Link_TXT, Link_URL],
121
  )
122
 
 
44
  def __init__(self):
45
  self.examples_text = []
46
 
47
+
48
  def get_new_parser(self, url):
49
  article = Article(url, language='ko')
50
  article.download()
 
73
  self.examples_text.append([get_summary(article.text[:1500]), news_url])
74
 
75
 
 
 
 
 
 
 
 
 
 
 
76
  title = "๊ท ํ˜•์žกํžŒ ๋‰ด์Šค ์ฝ๊ธฐ (Balanced News Reading)"
77
 
78
 
79
 
80
  with gr.Blocks(theme='pseudolab/huggingface-korea-theme') as demo:
81
+
82
+ collector = news_collector()
83
+ collector.update_news_examples()
84
 
85
  with gr.Tab("์†Œ๊ฐœ"):
86
  gr.Markdown(
 
104
  inputs = Link_TXT)
105
  Link_URL = gr.Textbox(label="๋‰ด์Šค URL")
106
 
107
+ # diable due to dynamic loading
108
+ # update_button = gr.Button(value="๋‰ด์Šค ๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ")
109
+ # update_button.click(fn=collector.update_news_examples_and_update, inputs=None, outputs=None)
110
 
111
  gr.Examples(
112
+ collector.examples_text,
113
  [Link_TXT, Link_URL],
114
  )
115