I got this error. As you can see I have import nltk and nltk.download in my code per their guide.:
[nltk_data] Error loading words: <urlopen error [SSL:
[nltk_data] CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data] unable to get local issuer certificate (_ssl.c:1000)>
My Code:
import re # To remove regular expressions. Like ? ! . ,
import tkinter as tk # This is a graphical UI
from tkinter.scrolledtext import ScrolledText # Widget
import nltk
nltk.download('words') # Check wether a word is valid
from nltk.corpus import words
class SpellingChecker:
def __init__(self):
self.root = tk.Tk() # tk.Tk refers to a class within the Tkinter module, which is a standard GUI
self.root.geometry("600x500")
self.text = ScrolledText(self.root, font=("Helvetica", 14))
self.text.bind("<KeyRelease>", self.check) # To check words whenever we release a key
self.text.pack()
self.old_spaces = 0 # By default we have 0 whitespaces
self.root.mainloop() # To get the GUI running
def check(self, event):
content = self.text.get("1.0", tk.END) # 1.0 is the first character, 1.1 is the second character, 1.2 is the third character etc. # tk.END this gives the full content of the text box
space_count = content.count(" ") # Count the white spaces
if space_count != self.old_spaces: # If space count is not the same, != as self.old_spaces
self.old_spaces = space_count
for tag in self.text.tag_names():
self.text.tag_delete(tag)
for word in content.split(" "):
if re.sub(r"[^\w]", "", word.lower()) not in words.words():
position = content.find(word)
self.text.tag_add(word, f"1.{position}", f"1.{position + len(word)}")
self.text.tag_config(word, foreground="red")
SpellingChecker()
I'm on MacOS and I got Python3 installed.
Searching for answers.
I tried to re add them, say nltk3, check forums, yt videos. nothing.
Used a VPN and then added some certificate code at the top.