This article will cover a list of useful grammar and spelling correction tools available for Linux. These applications mainly provide support for English language with a few of them having options for other languages as well. Note that you can use integrated spell checkers in applications like LibreOffice, Chrome, FireFox, AbiWord etc. to get correct spellings for your text based content. This article, however, mainly focuses on standalone spell checker applications that give you much more freedom to parse and fix spellings in your content and work with multiple applications.
LanguageTool
LanguageTool is an open source and cross-platform spell checking and grammar correction software. It supports over 20 languages, some of them are in development and have limited support. LanguageTool can parse any text in these supported languages, detect spelling mistakes, poor sentence construction and grammatical errors using various algorithms. It also provides suggestions to correct them automatically or manually. It is the best free alternative to premium grammar correction service “Grammarly”, though it comes with its own premium cloud based service that requires a monthly subscription plan to remove limits. It provides add-ons for FireFox and Chrome browsers as well as plugins for document editing software like LibreOffice, OpenOffice, Google Docs and Microsoft Word.
To get a build of LanguageTool that runs offline on various operating systems without any limits, you will have to download its desktop version. Strangely enough, LanguageTool maintainers never mention the desktop version on its website though it is very actively being developed. The website used to show an option to download desktop versions in the past, but not anymore. You can still download it from its file server using this direct link or browse all downloadable files from here. LanguageTool source code is available on GitHub. You can download various add-ons that work with certain limits from its homepage.
To run LanguageTool in Linux, you will need to install Java first. You can do so in Ubuntu by executing the command mentioned below:
You can install Java in other Linux distributions by searching for terms “Java” or “OpenJDK” in the package manager. Once you have Java installed on your Linux system, extract the desktop version downloaded from link above and run the following command from the extracted directory:
You can also run its command line build by using the command specified below:
To know more about its command line options, use the following command:
Write-good
Write-good is a Node.js library and command line utility that suggests edits for poor or uncommon sentence construction and writing style related errors. It does not provide suggestions for grammar extensively nor does it include a spell checker. It works by pointing out common sentence construction mistakes that increase complexity of written text. For instance, it actively checks for “passive” sentences and points out their usage.
To install Write-good in Ubuntu, use the following two commands:
$ sudo npm install -g write-good
If you are using any other Linux distribution, you can get the “npm” package from official repositories. Once you have “npm” installed on your Linux system, just run the second command mentioned above.
To check a chunk of text, use a command in the following format:
To parse an entire file, use a command in following format:
For further information, run the following command:
You can know more about its detection methodology and algorithms from here.
Aspell
“Aspell” or “GNU Aspell” is a command line spell checking program that is included by default in most Linux distributions. It is being developed as a replacement for another popular spell-checker for Linux called “Ispell”. Aspell can be used as a library in other programs as well as a standalone app. It claims to provide better and accurate spell results than Ispell and Microsoft Word.
To install Aspell in Ubuntu, use the command specified below:
You can install Aspell in other distributions from default repositories. Source code is available here.
Aspell features an interactive shell where you can get real time spell checking results. You can invoke it using this command:
To check an entire file, use a command in the following format:
To change the language of spell-checker, use the “–lang” switch. To know more about valid language codes and its numerous other options, run the following three commands:
$ aspell --help
$ man aspell
Hunspell
Hunspell is a popular spell checking application and library used in many popular open source programs like LibreOffice, Google Chrome / Chromium and Firefox. Besides spell checking, Hunspell can also generate stemming, n-gram similarity and morphological analysis data.
To install Hunspell in Ubuntu, use the command specified below:
You can install Hunspell in other distributions from default repositories. Source code is available here.
To run Hunspell’s interactive shell that gives real time results, use a command in the following format:
You can replace “en_US” with your own language code. Additional languages can be installed from your distribution’s package manager, they usually look like “hunspell-<lang-code>”.
To check an entire file, use a command in the following format:
To know more about Hunspell’s numerous other options, run the following two commands:
$ man hunspell
System Wide Popup Spell Checker Using Onboard Virtual Keyboard
Onboard is an on-screen / virtual keyboard available in many popular Linux distributions. It features numerous options to customize keyboard into different layouts, a spell-checker, touch friendly controls, automatic orientation and so on. Onboard is probably the most robust on-screen keyboard solution available today for Linux because of the sheer number of customization options it offers and overall user friendliness.
To install Onboard in Ubuntu, execute the command specified below:
You can install Onboard in other Linux distributions from their official repositories. Further information about its packages can be found here.
Launch Onboard and type a word in a text editor. You should see a layout like this. The middle part of the top row shows auto-completion and next word predictions. The left part of the row shows spell-checking suggestions. Here it suggested “mango” for a mistyped word “mngo”. You can click on the arrow symbol to get more spelling suggestions. During my usage of Onboard, I found that the Onboard’s spelling suggestion bar works great in all GTK applications while its support for Qt and other non-GTK applications is hit or miss.
Now if you are using Onboard on a desktop PC, you may not need this huge keyboard sticking at bottom as you may be using a hardware keyboard to type words. Using its layout editing feature, you can remove everything from it so that only the spell-check bar is visible, as shown in the screenshot below:
You can drag edges of any Onboard keyboard layout to resize it, so you can resize the spell bar as well. The “x” button allows you to close Onboard while the “En” button allows you to change the language of spell checker and word predictor. This should work system wide in all GTK applications as soon as you launch onboard. To achieve this result, you have to follow a few straightforward steps:
Launch Onboard and click on its panel applet to open preferences.
Go to “Typing Assistance” and enable the “Show suggestions” checkbox.
Enable “Auto-show” to make Onboard popup automatically while editing text.
Go to the “Layout” tab and click on any layout of your choice. Click on “New” and then enter a new name for your custom layout. Let’s assume the name is “custom-layout” in this case. This will create a new layout by inheriting all files and data from to the “Compact” layout.
Click on “Open layouts folder” and edit your “custom-layout.onboard” file. Put the following code in it or remove other lines in the file so that in the end it looks like this:
<keyboard id="custom-layout" format="3.2" section="system" summary="Medium size desktop keyboard">
<include file="key_defs.xml"/>
<box border="0.5" spacing="1.5" orientation="vertical">
<!--- word suggestions -->
<panel filename="custom-layout-Alpha.svg" scan_priority="1">
<include file="word_suggestions.xml"/>
</panel>
</box>
</keyboard>
The code sample above removes all UI elements from Onboard except spell-check and word prediction bar. Restart Onboard and then choose your new layout to view the end result.
If somehow you make wrong edits to the “.onboard” layout file and Onboard fails to start, go to “$HOME/.local/share/onboard/layouts” folder and delete all files related to your custom layout (as shown in the screenshot below).
You can customize and resize Onboard to move it to any location on your desktop, so that it works like a popup spell checker while editing any text document. Do not that Onboard doesn’t seem to support selecting virtual keys and buttons through hardware keyboard. So you will have to select spelling suggestions through mouse or touch screen taps only (at least this is what I have found in my testing).
Conclusion
Spell checker applications in Linux are quite robust and are based on years of development. Even if you are using an application without a built-in spell checker, there are command line utilities and graphical applications to help you correct grammar and spellings.