Python Mp
Python Mp
INTRODUCTION
PROGRAM
EXPLANATION
OUTPUT
LIBRARIES USED
ACKNOWLEDGEMENT
iNTRODUCTION
Sentiment Analysis Tool
Users can enter a sentence or paragraph, and the system will determine
the sentiment score and classify it as Positive , Negative , or Neutral
.
Program
import tkinter as tk
import nltk
nltk.download("vader_lexicon")
sia = SentimentIntensityAnalyzer()
def analyze_sentiment():
if not text:
return
score = sia.polarity_scores(text)["compound"]
color = "#28a745"
color = "#dc3545"
else:
color = "#ffc107"
root.geometry("500x400")
root.configure(bg="#2C2F33")
text_input.pack(pady=5, padx=10)
analyze_button.pack(pady=10)
result_label.pack(pady=10)
root.mainloop()
Libraries used
📚 Libraries Used
1️⃣ Tkinter
🙌 Acknowledgment
This project is inspired by the need to analyze text sentiment in real
time using a simple and user-friendly interface.
Code Explanation
import tkinter as tk
import nltk
nltk: The Natural Language Toolkit, which includes tools for text
processing.
nltk.download("vader_lexicon")
python
CopyEdit
sia = SentimentIntensityAnalyzer()
python
CopyEdit
def analyze_sentiment():
if not text:
return
python
CopyEdit
score = sia.polarity_scores(text)["compound"]
python
CopyEdit
color = "#28a745"
color = "#dc3545"
else:
color = "#ffc107"
CopyEdit
python
CopyEdit
root = tk.Tk()
root.geometry("500x400")
root.configure(bg="#2C2F33")
python
CopyEdit
python
CopyEdit
text_input.pack(pady=5, padx=10)
python
CopyEdit
analyze_button.pack(pady=10)
python
CopyEdit
result_label.pack(pady=10)
python
CopyEdit
root.mainloop()
Starts the Tkinter event loop, keeping the window open and
responsive.
📌 Summary