Adit712 commited on
Commit
3129490
1 Parent(s): 81b7bf6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ # Define the sentiment analysis function
5
+ def analyze_sentiment(text):
6
+ blob = TextBlob(text)
7
+ polarity = blob.sentiment.polarity
8
+ subjectivity = blob.sentiment.subjectivity
9
+ sentiment = "POSITIVE" if polarity >= 0 else "NEGATIVE"
10
+ return f"Sentiment: {sentiment}\nPolarity: {polarity:.2f}\nSubjectivity: {subjectivity:.2%}"
11
+
12
+ # Create a Gradio interface
13
+ iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")
14
+ iface.launch()