Spaces:
Runtime error

aaa / app.py
AbdulQadoos's picture
Create app.py
94e3e70
Raw History Blame Contribute Delete
848 Bytes
import gradio as gr
import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
nltk.download('vader_lexicon') # Ensure VADER lexicon is downloaded
def analyze_sentiment(text):
sid = SentimentIntensityAnalyzer()
sentiment_scores = sid.polarity_scores(text)
if sentiment_scores['compound'] >= 0.05:
sentiment = 'Positive'
elif sentiment_scores['compound'] <= -0.05:
sentiment = 'Negative'
else:
sentiment = 'Neutral'
return sentiment, sentiment_scores
iface = gr.Interface(
fn=analyze_sentiment,
inputs=[gr.Textbox(lines=5, placeholder="Enter your text here")],
outputs=[gr.Textbox(label="Sentiment"), gr.JSON(label="Sentiment Scores")],
title="Sentiment Analyzer by Qadoos Shaikh",
description="Analyze the sentiment of your text using VADER",
)
iface.launch()