Spaces:
Sleeping
Sleeping
File size: 744 Bytes
2223b50 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import gradio as gr
positive_words = ["good", "great", "happy", "love", "awesome", "fantastic", "excellent", "amazing"]
negative_words = ["bad", "sad", "terrible", "hate", "awful", "worst", "horrible", "disappointing"]
def analyze_sentiment(text):
text = text.lower()
pos_count = sum(word in text for word in positive_words)
neg_count = sum(word in text for word in negative_words)
if pos_count > neg_count:
return "Positive π"
elif neg_count > pos_count:
return "Negative π"
else:
return "Neutral π"
demo = gr.Interface(fn=analyze_sentiment,
inputs="text",
outputs="text",
title="Simple Sentiment Analyzer")
demo.launch() |