During English class, while checking my written English text for spelling mistakes. I started wondering about how spell checkers worked. So I created this spell checker (in C++) to learn more about spell checkers.
Note: By spell checker, I mean checking the text for spelling mistakes, not the process for suggesting words.
How it works
Before the spell checker can check the spelling of the given input, it needs to load a dictionary into memory. This spell checker uses a .txt file with 1,1 million words that are getting loaded into memory as a trie structure.
Once the dictionary is loaded into memory, the spell checker will loop through all the words in the given input. it looks up each word in the “trie” data structure. If the spell checker can find the word it means it exists and is spelled correctly. If it’s not able to find it, it means the word is spelled incorrectly or doesn’t exist.
Once the spell checker is done examining all the words, it will print back all the misspelled words to the console.
An example of a trie data structure:
To run the spell checker you’ll need to use the command in the command line:
./SpellChecker <option> <argument>
As option you can use:
- -s (Will spell check an as argument given string of text.)
- -f (Will spell check an as argument given file.)
|Technologies used:||C++, .txt, Spell Checking|
|Team size:||1 Programmer (me)|