Moncey10's picture
Update app.py
73ee4c2 verified
raw
history blame contribute delete
873 Bytes
import nltk
nltk.download('stopwords')
import gradio as gr
from src.models.inference import SentimentModel
model = SentimentModel()
def predict(text):
if not text.strip():
return "Please enter some text."
result = model.predict(text)
emoji_map = {
"positive": "😊 Positive",
"negative": "😞 Negative",
"neutral": "😐 Neutral"
}
return emoji_map.get(result.lower(), result)
demo = gr.Interface(
fn=predict,
inputs=gr.Textbox(
label="Enter your text",
placeholder="Type something here...",
lines=4
),
outputs=gr.Textbox(label="Sentiment Result"),
title="🎭 Sentiment Analyzer",
description="Enter any text and find out whether the sentiment is Positive, Negative, or Neutral.",
)
demo.launch(theme=gr.themes.Soft())