Spaces:
Sleeping
Sleeping
| 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()) | |