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