Triomphanrt commited on
Commit
9f7f267
·
verified ·
1 Parent(s): e741caa

firts_commit

Browse files
Files changed (1) hide show
  1. S_A_Front +45 -0
S_A_Front ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #vader-lexicon model with NLTK
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ import tkinter as tk
5
+ from tkinter import messagebox
6
+ from transformers import pipeline
7
+
8
+ model_id = "cardiffnlp/twitter-xlm-roberta-base-sentiment-multilingual"
9
+ classifier = pipeline("sentiment-analysis", model=model_id)
10
+
11
+ def process_string(input_string):
12
+ result = classifier(input_string)
13
+ if result[0]['label'] == 'positive':
14
+ return 'This comment is: positive 😃'
15
+ elif result[0]['label'] == 'negative':
16
+ return 'This comment is: negative 😒'
17
+ else:
18
+ return 'This comment is: positive 😃'
19
+
20
+ def process_input():
21
+ input_string = entry.get()
22
+ if input_string.strip() == "":
23
+ messagebox.showerror("Error", "Please enter a text.")
24
+ else:
25
+ processed_string = process_string(input_string)
26
+ messagebox.showinfo("Sentiment", f"Comment: {input_string}\n{processed_string}")
27
+ # Create the main application window
28
+ root = tk.Tk()
29
+ root.title("Sentiment Analyser: Hugging face 😃😒")
30
+
31
+ # Set the size of the window
32
+ root.geometry("500x100")
33
+
34
+ # Create and place widgets
35
+ label = tk.Label(root, text="Enter a text:")
36
+ label.pack()
37
+
38
+ entry = tk.Entry(root, width=80)
39
+ entry.pack()
40
+
41
+ button = tk.Button(root, text="Process", command=process_input, bg='green', fg='white')
42
+ button.pack()
43
+
44
+ # Run the Tkinter event loop
45
+ root.mainloop()