logu29 commited on
Commit
c00e8ff
·
verified ·
1 Parent(s): 4fdc6d0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ def analyze(text):
5
+ blob = TextBlob(text)
6
+ polarity = blob.sentiment.polarity
7
+ sentiment = "Positive" if polarity > 0 else "Negative" if polarity < 0 else "Neutral"
8
+ return f"Sentiment: {sentiment} (Polarity: {polarity:.2f})"
9
+
10
+ iface = gr.Interface(fn=analyze, inputs="text", outputs="text")
11
+ iface.launch()