'How to show the spacy output in tkinter textbox
I want to show the spacy output in my second textbox from tkinter, however I just manage to read the text file that i want to tokenize, I need to read the spacy output with the text file already tokenized, this is how it's my code to show the pre-tokenize text, how can i get the spacy output in the textbox?
nlp = es_core_news_sm.load()
doc = nlp(open('rainbow.txt').read())
for token in doc:
print(token.text,",")
def tokenize():
stuff2 = doc=nlp(open('rainbow.txt').read())
my_text2.insert(END, stuff2)
text_file.close()
open_button2 = Button(root, text="Compilar", command=tokenize)
open_button2.place(x=5,y=5)
root.mainloop()
I need to get the
print(token.text,",")
output for the button 2
I need to get the print token output for the textbox 2
Solution 1:[1]
This standalone code should work for what you are trying to do. You might have to change a few things back because I dont have spacy not do I know how to use it, and I dont have the same files that you have.
nlp = es_core_news_sm.load()
doc = nlp(open('rainbow.txt').read())
for token in doc:
print(token.text,",")
def tokenize():
stuff2 = token.text, ","
my_text2.insert(END, stuff2)
open_button2 = Button(root, text="Compilar", command=tokenize)
open_button2.place(x=5,y=5)
root.mainloop()
You can run this code and see why/how it works and work off of that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
