Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from textblob import TextBlob
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
def classify_sentiment(text):
|
| 5 |
+
blob = TextBlob(text)
|
| 6 |
+
polarity = blob.sentiment.polarity
|
| 7 |
+
|
| 8 |
+
if polarity > 0:
|
| 9 |
+
return "Positive"
|
| 10 |
+
elif polarity < 0:
|
| 11 |
+
return "Negative"
|
| 12 |
+
else:
|
| 13 |
+
return "Neutral"
|
| 14 |
+
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=classify_sentiment,
|
| 17 |
+
inputs=gr.Textbox(lines=2, placeholder="Type your sentence here..."),
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="Sentiment Analysis App",
|
| 20 |
+
description="Classify text into Positive, Negative, or Neutral using TextBlob."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
if _name_ == "_main_":
|
| 24 |
+
demo.launch()
|