Spaces:
Runtime error
Runtime error
File size: 652 Bytes
76c6334 4066f8e 76c6334 4066f8e 76c6334 4066f8e de1b425 4066f8e 2e37ab6 4066f8e de1b425 4066f8e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio as gr
from textblob import TextBlob
def analyze_sentiment(text):
blob = TextBlob(text)
sentiment = blob.sentiment.polarity
if sentiment > 0:
color = "green"
label = "Positive"
elif sentiment < 0:
color = "red"
label = "Negative"
else:
color = "yellow"
label = "Neutral"
return color, label
def sentiment_analysis(text):
color, label = analyze_sentiment(text)
return "<h2 style='color:{}; text-align:center;'>{} Sentiment</h2>".format(color, label)
iface = gr.Interface(
fn=sentiment_analysis,
inputs="text",
outputs="html"
)
iface.launch()
|