If you are a developer or simply a command-line geek/fan, there are times where you type some documents using the command line, like for README's or for documentation. It is also important to have a very good writing in English if you wish to distribute those files.
Hunspell can help you with spell-checking. It is based on MySpell and contains a nice terminal interface to spell-check your files.
For Ubuntu/Debian, Hunspell can be installed using Synaptic or apt. The package name is hunspell, but you might also want to install some dictionaries, like: hunspell-en-us for an american-english dictionary or hunspell-fr for a french dictionary, etc... (just search for hunspell in Synaptic).
To ease the process, you can type this command in a terminal:
sudo apt-get install hunspell hunspell-en-us
To start the spell-check on a file, just type this command:
hunspell -d en_US yourfile.txt
The -d option defines the dictionary to use, in this case we choose the american-english dictionary.
This will open a ncurses interface resembling to a spell-check window in common word processors. (See screenshot)
From there you can (source: hunspell manpage):
- Type a number to choose the corresponding correction
- R Replace the misspelled word completely.
- Space Accept the word this time only.
- A Accept the word for the rest of this hunspell session.
- I Accept the word, capitalized as it is in the file, and update private dictionary.
- U Accept the word, and add an uncapitalized (actually, all lower-case) version to the private dictionary.
- S Ask a stem and a model word and store them in the private dictionary. The stem will be accepted also with the affixes of the model word.
- X Write the rest of this file, ignoring misspellings, and start next file.
- Q Exit immediately and leave the file unchanged.
- ? Give help screen.
This will automatically change the given file with the corrections you chose/made.
Another possible way to use hunspell is through pipes, but it's less convenient:
echo "I'm jusst tetsting pipes to do some spell check rigth nows" | hunspell -d en_US
And this will give you:
Hunspell 1.2.6 * & jusst 2 4: justs, just & tetsting 2 10: testing, stetting + pipe * * * * * & rigth 4 48: right, girth, rig th, rig-th + now
This is not very easy to understand these lines.
But these can be summarized as follows:
- OK: *
- Root: + <root>
- Compound: -
- Miss: & <original> <count> <offset>: <miss>, <miss>, ...
- None: # <original> <offset>
I guess this is more for parsing using another application.
Conclusion, Hunspell is a very neat tool to use in a terminal!