I need to implement a spell checker in C. Basically, I need all the standard operations... I need to be able to spell check a block of text, make word suggestions and dynamically add new words to the index.
I'd kind of like to write this myself, tho I really don't know where to begin.
An ordinary spell checker will find few or no errors in the above sentence. This is because spell checkers can only detect if words are spelled correctly, not if they are used correctly. That being said, a spell checker is a handy tool and, therefore, should not be completely abandoned.
Spell Checkers do not always recognize proper nouns, which are names of people, places, and terms. Many will try to either correct them into something else, or just flag them as errors.
Spell check lets you know when words are misspelled, corrects misspelled words as you type, and allows you to search a whole document for misspelled words.
In Microsoft Word documents, Word's spell check function is set to automatically check your spelling while you type. Errors in your document will have color-coded underlines reflecting your choices, like red for spelling errors, green for grammar errors, and blue for contextual spelling errors.
Read up on Tree Traversal. The basic concept is as follows:
A really short example:
Dictionary:
apex apple appoint appointed
Tree: (*
indicates valid end of word) update: Thank you to Curt Sampson for pointing out that this data structure is called a Patricia Tree
A -> P -> E -> X*
\\-> P -> L -> E*
\\-> O -> I -> N -> T* -> E -> D*
Document:
apple appint ape
Results:
A -> P -> P
, but the second P
does not have an I
child node, so the search fails. E
node in A -> P -> E
does not have the "valid end of word" flag set. edit: For more details on spelling suggestions, look into Levenshtein Distance, which measures the smallest number of changes that must be made to convert one string into another. The best suggestions would be the dictionary words with the smallest Levenshtein Distance to the incorrectly spelled word.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With