cyrus-spc commited on
Commit
f507699
Β·
verified Β·
1 Parent(s): c969809

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ def analyze_sentiment(text):
5
+ blob = TextBlob(text)
6
+ polarity = blob.sentiment.polarity
7
+ if polarity > 0:
8
+ sentiment = "Positive πŸ˜€"
9
+ elif polarity < 0:
10
+ sentiment = "Negative 😞"
11
+ else:
12
+ sentiment = "Neutral 😐"
13
+ return f"Sentiment: {sentiment}\nPolarity Score: {polarity:.2f}"
14
+
15
+ iface = gr.Interface(
16
+ fn=analyze_sentiment,
17
+ inputs=gr.Textbox(lines=3, placeholder="Enter text here..."),
18
+ outputs="text",
19
+ title="Sentiment Analysis",
20
+ description="Enter text to analyze its sentiment (positive, negative, or neutral)."
21
+ )
22
+
23
+ if __name__ == "__main__":
24
+ iface.launch()