QuantumEcho Text Analyzer Python GUI
👤 Sharing: AI
import tkinter as tk
from tkinter import ttk
from tkinter import scrolledtext
import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from collections import Counter
import random
nltk.download('vader_lexicon', quiet=True)
nltk.download('punkt', quiet=True)
def analyze_text():
text = text_area.get("1.0", tk.END)
# Sentiment Analysis
sid = SentimentIntensityAnalyzer()
sentiment_scores = sid.polarity_scores(text)
# Keyword Extraction
words = nltk.word_tokenize(text)
words = [word.lower() for word in words if word.isalpha()]
word_counts = Counter(words)
top_keywords = word_counts.most_common(10)
# Basic Stats
num_chars = len(text)
num_words = len(words)
num_sentences = len(nltk.sent_tokenize(text))
# Display Results
sentiment_label.config(text=f"Sentiment: {sentiment_scores}")
keywords_label.config(text=f"Top Keywords: {top_keywords}")
stats_label.config(text=f"Stats: Characters={num_chars}, Words={num_words}, Sentences={num_sentences}")
def show_details():
details_window = tk.Toplevel(root)
details_window.title("Program Details")
details_text = tk.Text(details_window, wrap=tk.WORD)
details_text.pack(padx=10, pady=10)
details_text.insert(tk.END, "QuantumEcho Text Analyzer is a versatile tool for analyzing text. It performs sentiment analysis to determine the overall tone (positive, negative, neutral). It extracts the most frequent keywords to identify the main themes. It also provides basic statistics like the number of characters, words, and sentences. This program can be used for analyzing customer feedback, reviewing documents, or gaining insights from any text-based data.")
details_text.config(state=tk.DISABLED)
# GUI Setup
root = tk.Tk()
root.title("QuantumEcho Text Analyzer")
# Text Input
text_area = scrolledtext.ScrolledText(root, width=80, height=15)
text_area.pack(padx=10, pady=10)
# Analyze Button
analyze_button = ttk.Button(root, text="Analyze Text", command=analyze_text)
analyze_button.pack(pady=5)
# Result Labels
sentiment_label = tk.Label(root, text="Sentiment: ")
sentiment_label.pack()
keywords_label = tk.Label(root, text="Top Keywords: ")
keywords_label.pack()
stats_label = tk.Label(root, text="Stats: ")
stats_label.pack()
# Details Button
details_button = ttk.Button(root, text="Details", command=show_details)
details_button.pack(pady=5)
root.mainloop()
👁️ Viewed: 6
Comments