CoolFace
Apppublic

AryanDhiman/sentiment_analysis

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
app.py14 linesDownload Raw Back to root
1import gradio as gr2from textblob import TextBlob3 4# Define the sentiment analysis function5def analyze_sentiment(text):6	blob = TextBlob(text)7	polarity = blob.sentiment.polarity8	subjectivity = blob.sentiment.subjectivity9	sentiment = "POSITIVE" if polarity >= 0 else "NEGATIVE"10	return f"Sentiment: {sentiment}\nPolarity: {polarity:.2f}\nSubjectivity: {subjectivity:.2%}"11 12# Create a Gradio interface13iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")14iface.launch()