#vader-lexicon model with NLTK import pandas as pd import matplotlib.pyplot as plt import tkinter as tk from tkinter import messagebox from transformers import pipeline model_id = "cardiffnlp/twitter-xlm-roberta-base-sentiment-multilingual" classifier = pipeline("sentiment-analysis", model=model_id) def process_string(input_string): result = classifier(input_string) if result[0]['label'] == 'positive': return 'This comment is: positive 😃' elif result[0]['label'] == 'negative': return 'This comment is: negative 😒' else: return 'This comment is: positive 😃' def process_input(): input_string = entry.get() if input_string.strip() == "": messagebox.showerror("Error", "Please enter a text.") else: processed_string = process_string(input_string) messagebox.showinfo("Sentiment", f"Comment: {input_string}\n{processed_string}") # Create the main application window root = tk.Tk() root.title("Sentiment Analyser: Hugging face 😃😒") # Set the size of the window root.geometry("500x100") # Create and place widgets label = tk.Label(root, text="Enter a text:") label.pack() entry = tk.Entry(root, width=80) entry.pack() button = tk.Button(root, text="Process", command=process_input, bg='green', fg='white') button.pack() # Run the Tkinter event loop root.mainloop()