Adit712's picture
Create app.py
3129490
raw
history blame contribute delete
492 Bytes
import gradio as gr
from textblob import TextBlob
# Define the sentiment analysis function
def analyze_sentiment(text):
blob = TextBlob(text)
polarity = blob.sentiment.polarity
subjectivity = blob.sentiment.subjectivity
sentiment = "POSITIVE" if polarity >= 0 else "NEGATIVE"
return f"Sentiment: {sentiment}\nPolarity: {polarity:.2f}\nSubjectivity: {subjectivity:.2%}"
# Create a Gradio interface
iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")
iface.launch()