vivekkumarbarman commited on
Commit
750f86e
1 Parent(s): 7d5896a

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +14 -0
  2. requirements.txt +2 -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()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ textblob