feat: Initial commit
This commit is contained in:
42
spellcheck.py
Normal file
42
spellcheck.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from os import WNOHANG
|
||||
|
||||
|
||||
def clean(word: str):
|
||||
a = len(word)
|
||||
|
||||
while True:
|
||||
word = word.strip("()[]{}!?.,<>:;-_`’‘")
|
||||
if a == len(word):
|
||||
break
|
||||
|
||||
a = len(word)
|
||||
|
||||
return word
|
||||
|
||||
def file_to_set(filename: str, clear: bool):
|
||||
dfio = open(filename, "r", encoding="cp1252")
|
||||
words = set()
|
||||
|
||||
for line in dfio:
|
||||
for word in line.strip().split():
|
||||
if clear:
|
||||
word = clean(word)
|
||||
if word == "":
|
||||
continue
|
||||
|
||||
words.add(word.lower())
|
||||
|
||||
dfio.close()
|
||||
|
||||
return words
|
||||
|
||||
|
||||
def main():
|
||||
dictionary = file_to_set("words.txt", False)
|
||||
document = file_to_set("ge.txt", True)
|
||||
misspelling = dictionary.difference(document)
|
||||
|
||||
for word in sorted(misspelling):
|
||||
print(word)
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user