File size: 368 Bytes
c00e8ff
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
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()