-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpellChecker.py
More file actions
28 lines (19 loc) · 823 Bytes
/
SpellChecker.py
File metadata and controls
28 lines (19 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from english_words import get_english_words_set
from rich import print
wordList = get_english_words_set(['web2'], lower=True)
def CheckWords(argWordList: str) -> list[str]:
"""Checks if words are correct by looping through provided string and checking if the lowered string is in the Standard English Dictionary"""
checked = []
for word in argWordList.split():
if word.casefold() in wordList:
checked.append(f"[green]{word}[/green]")
else:
checked.append(f"[red]{word}[/red]")
return checked
# Main Loop
while True:
userInput = input("Please type in a sentence and press enter to check: ")
checkedWorldList = CheckWords(userInput)
# Turns List to string
consoleOutput = " ".join(checkedWorldList)
print(consoleOutput)