Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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")
|