Spaces:
Sleeping
Sleeping
File size: 873 Bytes
f5352ab 3690686 52697ea 3690686 52697ea 5363b45 52697ea 5363b45 3690686 52697ea 5363b45 73ee4c2 3690686 fdd619b 3690686 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 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())
|