logu29's picture
Create app.py
c00e8ff verified
raw
history blame
368 Bytes
import gradio as gr
from textblob import TextBlob
def analyze(text):
blob = TextBlob(text)
polarity = blob.sentiment.polarity
sentiment = "Positive" if polarity > 0 else "Negative" if polarity < 0 else "Neutral"
return f"Sentiment: {sentiment} (Polarity: {polarity:.2f})"
iface = gr.Interface(fn=analyze, inputs="text", outputs="text")
iface.launch()