Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Result not change using Tkinter
#1
Hello,

can someone help me? my problem is when I build my own prototype using Tkinter, the result is the same. But when I run my coding using Jupyter or spyder the result always changed with my model. How did I want to fix this? Thank you. Below is my code using Tkinter.
import pickle
from  tkinter import Tk,Label,Entry, Button,StringVar,RAISED,RIGHT,LEFT,messagebox
from sklearn.base import TransformerMixin
from nltk.corpus import stopwords
import spacy
import string
from spacy.lang.en import English
from sklearn.feature_extraction.stop_words import ENGLISH_STOP_WORDS

spacy.load('en')
parser = English()

STOPLIST = set(stopwords.words('english') + list(ENGLISH_STOP_WORDS))
SYMBOLS = ["-", "...", "”", "”"]

SYMBOLS_PUNC = " ".join(string.punctuation).split(" ") + ["-", "...", "”", "”"]

class CleanTextTransformer(TransformerMixin):
    def transform(self, X, **transform_params):
        return [cleanText(text) for text in X]
    def fit(self, X, y=None, **fit_params):
        return self
    def get_params(self, deep=True):
        return {}
    
def cleanText(text):
    text = text.strip().replace("\n", " ").replace("\r", " ")
    text = text.lower()
    return text

def tokenizeText(sample):
    tokens = parser(sample)
    lemmas = []
    for tok in tokens:
        lemmas.append(tok.lemma_.lower().strip() if tok.lemma_ != "-PRON-" else tok.lower_)
    tokens = lemmas
    tokens = [tok for tok in tokens if tok not in STOPLIST]
    tokens = [tok for tok in tokens if tok not in SYMBOLS_PUNC]
    return tokens

def detecting_fake_news(var):  
#retrieving the best model for prediction call
    load_model = pickle.load(open('svmCombine_model.sav', 'rb'))
    prediction = load_model.predict([var])
    prob = load_model.predict_proba([var])

    return (messagebox.showinfo("The given statement is ",prediction[0]),
        messagebox.showinfo("The truth probability score is ",prob[0][1]))

def e1_delete():
    title.delete(first=0,last=100)
    content.delete(first=0,last=100)
    title.insert(0, " ")
    content.insert(0, " ")
    return
    

def master_destroy():
     master.destroy()
    

master=Tk()
master.title("===== DECEPTION DETECTION IN ONLINE NEWS VERACITY =====")
master.geometry("800x500+200+250")

label0=Label(master, bg='gold', text="     Deception Online News     ", relief=RAISED)
label0.pack(padx=20, pady=30)


number1Label = Label (text="Enter Title: ")
number1Label.pack()
title=Entry(master, width=100)
title.pack()

number2Label = Label (text="Enter Content: ")
number2Label.pack()
content=Entry(master, width=100)
content.pack(ipady=100)

var=StringVar()
var= title.get() + content.get()

bouton_recup=Button(master, text="Generate", relief=RAISED, command= lambda:detecting_fake_news(var))        
bouton_recup.pack(side=RIGHT, padx=5, pady=5)
        

b_erase=Button(master, text="Erase", relief=RAISED, command=e1_delete)
b_erase.pack(side=LEFT, padx=5, pady=5)

b_quit_destroy=Button(master, text="Quit",relief=RAISED, command=master_destroy)
b_quit_destroy.pack(side=LEFT, padx=5, pady=5)

master.mainloop()
Yoriz wrote May-17-2019, 06:35 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote
#2
See the following posts
https://python-forum.io/Thread-Tkinter-N...t-updating
https://python-forum.io/Thread-Tkinter-T...7#pid78447
Quote
#3
Thank you Yoriz for your reply and also for the link. It helps me a lot! and solve my problem.

Thanks again. Big Grin
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] help please, checking the user input and outputting the result tomkovladko 3 195 Mar-05-2019, 08:58 PM
Last Post: joe_momma

Forum Jump:


Users browsing this thread: 1 Guest(s)