Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,20 +8,6 @@ def analyze_sentiment(text):
|
|
| 8 |
sentiment = result[0]['label']
|
| 9 |
return sentiment
|
| 10 |
|
| 11 |
-
def update_language(language):
|
| 12 |
-
if language == "العربية":
|
| 13 |
-
return (
|
| 14 |
-
gr.update(label="أدخل النص", placeholder="اكتب جملة أو فقرة هنا ^^..."),
|
| 15 |
-
gr.update(label="المشاعر المتوقعة (من 1 إلى 5)"),
|
| 16 |
-
"تحليل المشاعر"
|
| 17 |
-
)
|
| 18 |
-
else: # Default to English
|
| 19 |
-
return (
|
| 20 |
-
gr.update(label="Enter Text", placeholder="Type a sentence or paragraph here ^^..."),
|
| 21 |
-
gr.update(label="Predicted Sentiment (1-5) star"),
|
| 22 |
-
"Analyze Sentiment"
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
examples = [
|
| 26 |
["I love this product! It's amazing!"],
|
| 27 |
["This was the worst experience I've ever had."],
|
|
@@ -29,25 +15,21 @@ examples = [
|
|
| 29 |
["Absolutely fantastic! I would recommend it to everyone."]
|
| 30 |
]
|
| 31 |
|
| 32 |
-
#
|
| 33 |
with gr.Blocks() as demo:
|
| 34 |
-
gr.Markdown("## Sentiment Analysis
|
| 35 |
-
|
| 36 |
-
language_choice = gr.Radio(["العربية", "English"], label="اختر اللغة", value="English")
|
| 37 |
|
| 38 |
with gr.Row():
|
| 39 |
with gr.Column():
|
| 40 |
text_input = gr.Textbox(label="Enter Text", placeholder="Type a sentence or paragraph here ^^...")
|
| 41 |
|
| 42 |
with gr.Column():
|
| 43 |
-
output = gr.Textbox(label="Predicted Sentiment (1-5)", interactive=False)
|
| 44 |
|
| 45 |
-
analyze_button = gr.Button("Analyze Sentiment")
|
| 46 |
|
| 47 |
gr.Examples(examples=examples, inputs=text_input)
|
| 48 |
|
| 49 |
analyze_button.click(analyze_sentiment, inputs=[text_input], outputs=output)
|
| 50 |
|
| 51 |
-
language_choice.change(update_language, inputs=[language_choice], outputs=[text_input, output, analyze_button])
|
| 52 |
-
|
| 53 |
demo.launch()
|
|
|
|
| 8 |
sentiment = result[0]['label']
|
| 9 |
return sentiment
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
examples = [
|
| 12 |
["I love this product! It's amazing!"],
|
| 13 |
["This was the worst experience I've ever had."],
|
|
|
|
| 15 |
["Absolutely fantastic! I would recommend it to everyone."]
|
| 16 |
]
|
| 17 |
|
| 18 |
+
#Gradio
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
+
gr.Markdown("## Sentiment Analysis")
|
|
|
|
|
|
|
| 21 |
|
| 22 |
with gr.Row():
|
| 23 |
with gr.Column():
|
| 24 |
text_input = gr.Textbox(label="Enter Text", placeholder="Type a sentence or paragraph here ^^...")
|
| 25 |
|
| 26 |
with gr.Column():
|
| 27 |
+
output = gr.Textbox(label="Predicted Sentiment (1-5 stars)", interactive=False)
|
| 28 |
|
| 29 |
+
analyze_button = gr.Button("Analyze Sentiment", variant="primary")
|
| 30 |
|
| 31 |
gr.Examples(examples=examples, inputs=text_input)
|
| 32 |
|
| 33 |
analyze_button.click(analyze_sentiment, inputs=[text_input], outputs=output)
|
| 34 |
|
|
|
|
|
|
|
| 35 |
demo.launch()
|