import nltk from nltk.sentiment import SentimentIntensityAnalyzer # Download the vader_lexicon resource nltk.download('vader_lexicon') text = "I absolutely loved this movie! The acting was superb, the plot was engaging, and the cinematography was stunning. I would highly recommend it to anyone looking for a great film to watch.." analyzer = SentimentIntensityAnalyzer() scores = analyzer.polarity_scores(text) if scores['compound'] >= 0.05: print("Positive Sentiment") elif scores['compound'] <= -0.05: print("Negative Sentiment") else: print("Neutral Sentiment") import gradio as gr import nltk from nltk.sentiment import SentimentIntensityAnalyzer nltk.download('vader_lexicon') analyzer = SentimentIntensityAnalyzer() def analyze_sentiment(text): scores = analyzer.polarity_scores(text) if scores['compound'] >= 0.5: sentiment = "Very Positive 😃" elif scores['compound'] > 0 and scores['compound'] < 0.5: sentiment = "Positive 🙂" elif scores['compound'] == 0: sentiment = "Neutral 😐" elif scores['compound'] > -0.5 and scores['compound'] < 0: sentiment = "Negative 🙁" elif scores['compound'] <= -0.5: sentiment = "Very Negative 😠" elif "racist" in text.lower(): sentiment = "Racist 🤬" elif "annoying" in text.lower(): sentiment = "Annoying 😒" elif "boring" in text.lower(): sentiment = "Boring 😴" else: sentiment = "Unknown 😕" return sentiment, text iface = gr.Interface(fn=analyze_sentiment, inputs=gr.inputs.Textbox(label="Enter Text Here"), outputs=[gr.outputs.Textbox(label="Sentiment"), gr.outputs.Textbox(label="Input Text")], title="Sentiment Analysis", description="Enter a sentence and get the sentiment analysis result.") iface.launch()