js-spell-checker
Installation
npm i js-spell-checker -g
Usage
$ spell-checker c <dictonary-file> <file-to-check>
Limitations
The dictonary/file-to-check files must be plain text (*.txt). The words within those files must be seperated by new lines. I've provided a file-to-check in this repo with common misspellings that I used during testing. You can also find a dictonary file within this repo. The dictonary does not have every word like 'Friday', so before you assume it's broken check to see if the word exists in the dictonary.
Example Output
How does it work?
- A dictonary and a file to check for spelling errors are provided as command line arguments.
- Those files are read as plain text and parsed into Arrays.
- The file to check array is matched against the dictonary array. Any differences in the file to check array can be assumed as a misspelled word.
- The user is provided feedback in the console, that feedback consists of the misspelled word, the line number to find the misspelled word and suggestions on what they might have meant to spell.
- The suggestions are determined by breaking up each misspelled word into an array of characters. Those characters are looped over and transformed using characters out of an alphabet array.
- The suggestions are then matched against the dictonary to determine if the suggestion is indeed a word.
- The results are output to the console for the user to read.