Tayyaba888's picture
requirement.txt
2223b50 verified
raw
history blame contribute delete
744 Bytes
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()