I am a total newbie to Python and programming in general. I know I'd find more materials for Python2, but Python3 was a reflected choice.
That said, I have gone trough:
and tried to assemble my spell checker, and ended up with the following code:
#!/usr/bin/python3 # Filename: spellcheck2.py correct =  unknown =  dict_file = open("DictionaryE.txt", "r").readlines() for i in range(len(dict_file)): dict_file[i] = dict_file[i][0:len(dict_file[i])-2] #eliminate \n, line characters in the dictionary input_text = open("text.txt", "r").read() input_text = input_text.lower() #avoid problems with CAPS list_words = input_text.split(' ') print(list_words) for word in list_words: if word in dict_file: correct.append(word) else: unknown.append(word) print() print("Correct words are: ") print() for x in range(len(correct)): print(x+1, '\t', correct[x]) print() print("Unknown words are: ") print() for z in range(len(unknown)): print(z+1, '\t', unknown[z])
Please find attached the files with the dictionary and the sample text.
I really cannot understand why some words that certainly are in the dictionary (like "very" and "among") end up in the unknown words list. Any help would be welcome.
As a secondary issue, I couldn't figure out how to use multiple separators (in addition to space, also have punctuation) with the "split" command for lists.
Thanks in advance for any help.