GuidK commited on
Commit
9c93884
Β·
verified Β·
1 Parent(s): ba692a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -26,7 +26,7 @@ trans_model = AutoModelForSeq2SeqLM.from_pretrained(trans_model_name)
26
  def analyze_sentiment(text):
27
  # Check if text is empty or contains only spaces
28
  if not text or not text.strip():
29
- return {"Error: Please enter text for analysis": 0.0}
30
 
31
  # Escape HTML tags to protect against injections
32
  safe_text = html_lib.escape(text)
@@ -43,7 +43,7 @@ def analyze_sentiment(text):
43
  def summarize_text(text):
44
  # Check if text is empty or contains only spaces
45
  if not text or not text.strip():
46
- return "Error: Please enter text to summarize"
47
 
48
  # Escape HTML tags
49
  safe_text = html_lib.escape(text)
@@ -78,7 +78,7 @@ def summarize_text(text):
78
  def translate_en_to_uk(text):
79
  # Check if text is empty or contains only spaces
80
  if not text or not text.strip():
81
- return "Error: Please enter text to translate"
82
 
83
  # Escape HTML tags
84
  safe_text = html_lib.escape(text)
@@ -143,7 +143,7 @@ with gr.Blocks(title="NLP Toolkit", theme=gr.themes.Soft()) as demo:
143
  btn_summarize.click(fn=summarize_text, inputs=input_long, outputs=output_summary)
144
 
145
  # Add examples section header
146
- gr.Markdown("### πŸ“‹ Click an example button below to load text:")
147
  with gr.Row():
148
  sum_ex1 = gr.Button("πŸ’‘ AI Force")
149
  sum_ex2 = gr.Button("πŸš€ Space Telescope")
@@ -165,7 +165,7 @@ with gr.Blocks(title="NLP Toolkit", theme=gr.themes.Soft()) as demo:
165
  btn_translate.click(fn=translate_en_to_uk, inputs=input_trans, outputs=output_trans)
166
 
167
  # Add examples section header
168
- gr.Markdown("### πŸ“‹ Click an example button below to load text:")
169
  with gr.Row():
170
  trans_ex1 = gr.Button("πŸ€– AI Future")
171
  trans_ex2 = gr.Button("β˜• Coffee Order")
 
26
  def analyze_sentiment(text):
27
  # Check if text is empty or contains only spaces
28
  if not text or not text.strip():
29
+ return {"Error: Please enter the text for analysis": 0.0}
30
 
31
  # Escape HTML tags to protect against injections
32
  safe_text = html_lib.escape(text)
 
43
  def summarize_text(text):
44
  # Check if text is empty or contains only spaces
45
  if not text or not text.strip():
46
+ return "Error: Please enter the text to summarize"
47
 
48
  # Escape HTML tags
49
  safe_text = html_lib.escape(text)
 
78
  def translate_en_to_uk(text):
79
  # Check if text is empty or contains only spaces
80
  if not text or not text.strip():
81
+ return "Error: Please enter the text to translate"
82
 
83
  # Escape HTML tags
84
  safe_text = html_lib.escape(text)
 
143
  btn_summarize.click(fn=summarize_text, inputs=input_long, outputs=output_summary)
144
 
145
  # Add examples section header
146
+ gr.Markdown("### πŸ“‹ Click an example button below to load the text:")
147
  with gr.Row():
148
  sum_ex1 = gr.Button("πŸ’‘ AI Force")
149
  sum_ex2 = gr.Button("πŸš€ Space Telescope")
 
165
  btn_translate.click(fn=translate_en_to_uk, inputs=input_trans, outputs=output_trans)
166
 
167
  # Add examples section header
168
+ gr.Markdown("### πŸ“‹ Click an example button below to load the text:")
169
  with gr.Row():
170
  trans_ex1 = gr.Button("πŸ€– AI Future")
171
  trans_ex2 = gr.Button("β˜• Coffee Order")