theQuert commited on
Commit
21cd2e3
1 Parent(s): cc5df5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -39
app.py CHANGED
@@ -269,10 +269,8 @@ def main(input_article, input_trigger):
269
  # return updated_article, modified, merged_par_pred_df
270
  modified_in_all = str(len(paragraphs_needed)) + " / " + str(len(data_test))
271
 
272
- try:
273
- os.remove("./util/experiments/classification.csv")
274
- os.remove("./util/experiments/paragraphs_needed.csv")
275
- except: pass
276
  return updated_article, modified_in_all
277
 
278
  def copy_to_clipboard(t):
@@ -284,37 +282,10 @@ def compare_versions():
284
  old, new = [], []
285
  with open("./util/experiments/formatted_input.txt", "r") as f:
286
  old = f.read()
 
287
  with open("./util/experiments/updated_article.txt", "r") as f:
288
  new = f.read()
289
  return old, new
290
- """
291
- demo = gr.Interface(
292
- main,
293
- [
294
- gr.Textbox(
295
- lines=2, label="Non-updated Article", placeholder="Input the article..."
296
- ),
297
- gr.Textbox(
298
- lines=2, label="Triggered News Event", placeholder="Input the triggered news event..."
299
- )
300
- ],
301
- [
302
- gr.Textbox(
303
- lines=25,
304
- label="Output",
305
- ),
306
- gr.Textbox(
307
- lines=1,
308
- label="#MODIFIED/ALL"
309
- ),
310
- # btn = gr.Button(value="Copy Updated Article to Clipboard")
311
- # btn.click(copy_to_clipboard)
312
- # gr.components.Button(value="Copy Updated Article to Clipboard", fn=copy_to_clipboard),
313
- ],
314
- title="Event Triggered Article Updating System",
315
- description="Powered by YTLee",
316
- )
317
- """
318
 
319
  with open("./examples/non_update.txt", "r") as f:
320
  exin_1 = f.read()
@@ -342,7 +313,7 @@ with gr.Blocks() as demo:
342
  )
343
  with gr.Tab("Article Updating"):
344
  input_1 = gr.Textbox(label="Non-updated Article", lines=2, placeholder="Input the contexts...")
345
- input_2 = gr.Textbox(label="Triggered News Event", lines=2, placeholder="Input the triggered news event...")
346
  btn = gr.Button(value="Submit")
347
  with gr.Row():
348
  output_1 = gr.Textbox(label="Updated Article", lines=5)
@@ -367,12 +338,10 @@ with gr.Blocks() as demo:
367
  com_1 = gr.Textbox(label="Non-update Article", value=com_1_value, lines=15)
368
  com_2 = gr.Textbox(label="Updated Article", value=com_2_value, lines=15)
369
  btn_com.click(fn=compare_versions, inputs=[], outputs=[com_1, com_2])
370
- path_formatted_input = "./util/experiments/formatted_input.txt"
371
- path_updated_article = "./util/experiments/updated_article.txt"
372
- if os.path.isfile(path_formatted_input):
373
- os.remove(path_formatted_input)
374
- if os.path.isfile(path_updated_article):
375
- os.remove(path_updated_article)
376
  gr.HTML("""
377
  <div align="center">
378
  <p>
 
269
  # return updated_article, modified, merged_par_pred_df
270
  modified_in_all = str(len(paragraphs_needed)) + " / " + str(len(data_test))
271
 
272
+ os.remove("./util/experiments/classification.csv")
273
+ os.remove("./util/experiments/paragraphs_needed.csv")
 
 
274
  return updated_article, modified_in_all
275
 
276
  def copy_to_clipboard(t):
 
282
  old, new = [], []
283
  with open("./util/experiments/formatted_input.txt", "r") as f:
284
  old = f.read()
285
+ old = old.replace("[ADD]", "")
286
  with open("./util/experiments/updated_article.txt", "r") as f:
287
  new = f.read()
288
  return old, new
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
  with open("./examples/non_update.txt", "r") as f:
291
  exin_1 = f.read()
 
313
  )
314
  with gr.Tab("Article Updating"):
315
  input_1 = gr.Textbox(label="Non-updated Article", lines=2, placeholder="Input the contexts...")
316
+ input_2 = gr.Textbox(label="Triggered News Event", lines=1, placeholder="Input the triggered news event...")
317
  btn = gr.Button(value="Submit")
318
  with gr.Row():
319
  output_1 = gr.Textbox(label="Updated Article", lines=5)
 
338
  com_1 = gr.Textbox(label="Non-update Article", value=com_1_value, lines=15)
339
  com_2 = gr.Textbox(label="Updated Article", value=com_2_value, lines=15)
340
  btn_com.click(fn=compare_versions, inputs=[], outputs=[com_1, com_2])
341
+ formatted_input_path = "./util/experiments/formatted_input.txt"
342
+ updated_article_path = "./util/experiments/updated_article.txt"
343
+ if os.path.isfile(formatted_input_path): os.remove(formatted_input_path)
344
+ if os.path.isfile(updated_article_path): os.remove(updated_article_path)
 
 
345
  gr.HTML("""
346
  <div align="center">
347
  <p>