Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
|
| 3 |
+
|
| 4 |
+
analyzer = SentimentIntensityAnalyzer()
|
| 5 |
+
|
| 6 |
+
def analyze_sentiment(text):
|
| 7 |
+
score = analyzer.polarity_scores(text)['compound']
|
| 8 |
+
if score >= 0.05:
|
| 9 |
+
return "😊 Positive"
|
| 10 |
+
elif score <= -0.05:
|
| 11 |
+
return "😠 Negative"
|
| 12 |
+
else:
|
| 13 |
+
return "😐 Neutral"
|
| 14 |
+
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=analyze_sentiment,
|
| 17 |
+
inputs="text",
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="Simple Sentiment Analysis",
|
| 20 |
+
description="Enter text to analyze sentiment (Positive, Negative, Neutral)."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
iface.launch()
|