CoolFace
Apppublic

Swapnayadav/sentiment_analysis

sourceHugging Facemitupdated 9mo agoView on Hugging Face
0likes
app.py24 linesDownload Raw Back to root
1from textblob import TextBlob2import gradio as gr3 4def classify_sentiment(text):5    blob = TextBlob(text)6    polarity = blob.sentiment.polarity7    8    if polarity > 0:9        return "Positive"10    elif polarity < 0:11        return "Negative"12    else:13        return "Neutral"14 15demo = 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 23if __name__ == "__main__":24    demo.launch()