Spaces:
No application file
No application file
Update llm.apy
Browse files
llm.apy
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Simple dummy function for sentiment
|
| 4 |
+
def predict_sentiment(text):
|
| 5 |
+
positive_words = ['good', 'happy', 'awesome', 'best', 'fantastic', 'love']
|
| 6 |
+
negative_words = ['bad', 'sad', 'terrible', 'worst', 'hate', 'awful']
|
| 7 |
+
|
| 8 |
+
text = text.lower()
|
| 9 |
+
score = 0
|
| 10 |
+
|
| 11 |
+
for word in positive_words:
|
| 12 |
+
if word in text:
|
| 13 |
+
score += 1
|
| 14 |
+
for word in negative_words:
|
| 15 |
+
if word in text:
|
| 16 |
+
score -= 1
|
| 17 |
+
|
| 18 |
+
if score > 0:
|
| 19 |
+
return "Positive π"
|
| 20 |
+
elif score < 0:
|
| 21 |
+
return "Negative π"
|
| 22 |
+
else:
|
| 23 |
+
return "Neutral π"
|
| 24 |
+
|
| 25 |
+
# Build Gradio Interface
|
| 26 |
+
interface = gr.Interface(
|
| 27 |
+
fn=predict_sentiment,
|
| 28 |
+
inputs="text",
|
| 29 |
+
outputs="text",
|
| 30 |
+
title="Simple Sentiment Analyzer",
|
| 31 |
+
description="Enter a sentence and get the sentiment prediction!",
|
| 32 |
+
theme="default"
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# Launch the app
|
| 36 |
+
if __name__ == "__main__":
|
| 37 |
+
interface.launch()
|