llmcase / llm.apy
AhtashamMirza's picture
Update llm.apy
2812448 verified
raw
history blame contribute delete
898 Bytes
import gradio as gr
# Simple dummy function for sentiment
def predict_sentiment(text):
positive_words = ['good', 'happy', 'awesome', 'best', 'fantastic', 'love']
negative_words = ['bad', 'sad', 'terrible', 'worst', 'hate', 'awful']
text = text.lower()
score = 0
for word in positive_words:
if word in text:
score += 1
for word in negative_words:
if word in text:
score -= 1
if score > 0:
return "Positive πŸ˜€"
elif score < 0:
return "Negative 😞"
else:
return "Neutral 😐"
# Build Gradio Interface
interface = gr.Interface(
fn=predict_sentiment,
inputs="text",
outputs="text",
title="Simple Sentiment Analyzer",
description="Enter a sentence and get the sentiment prediction!",
theme="default"
)
# Launch the app
if __name__ == "__main__":
interface.launch()