DEV Community

Cover image for What do we say to typos? Not today!
Tobias Haindl
Tobias Haindl

Posted on • Updated on

What do we say to typos? Not today!

As we all know, typing frantically can lead to typos quite easily.

Since I'm not really proud of all the typos I produce during a normal work day, I decided to do something against it a few
weeks ago.

LanguageTool to the rescue

I was already used to wiggly lines in my favorite IDE IntelliJ and really missed the spell and grammar check capabilities in other editors especially when writing something in the browser.
A colleague told me that IntelliJ is using LanguageTool.

Therefore, I looked around on GitHub for a way of hosting my own LanguageTool server.
I came across this repository and decided to give it a go and run it on my Linux server.

Running your own instance with Docker

Setup n-gram support

For better analysis results we will download the n-gram dataset provided by LanguageTool.
N-grams can be used to distinguish between words which are easily confused like there and their or bite and byte. Depending on the context LanguageTool can make assumptions about the correct word with the help of the n-gram files.

To download all English n-grams in your current directory, execute:

Enter fullscreen mode Exit fullscreen mode

To unpack the downloaded zip file into the directory ngrams:

unzip -d ngrams
Enter fullscreen mode Exit fullscreen mode

If you want to add n-grams for an additional language, make sure to adhere to the directory structure.

E.g. for English and German:

Enter fullscreen mode Exit fullscreen mode

Pull and run the image

docker pull erikvl87/languagetool
Enter fullscreen mode Exit fullscreen mode

To pull the latest version from DockerHub.

docker run --rm -e langtool_languageModel=/ngrams -v /home/<insert-your-path-here>/ngrams:/ngrams -p 8010:8010 erikvl87/languagetool
Enter fullscreen mode Exit fullscreen mode

To run the LanguageTool server with n-gram analysis enabled.
Make sure to change <insert-your-path-here>/ngrams to your local ngrams directory which we previously created.

Install the Chrome plugin

To enable spell and grammar checking in Chrome install the corresponding plugin.
Head to the setting and set to URL to your LanguageTool Server:

LanguageTool configuration

It is important to add /v2 to the base path, otherwise the Chrome plugin won't work!

E.g. if your LanguageTool server is reachable under the configured URL should be https:/

After that the LanguageTool should be available to you.
In the editor it looks like this:

LanguageTool integration

Additional plugins can be found here.

That's all from me!
Thanks for reading!
Happy spell and grammar checking everyone!

Header image by Patrick Fore

Top comments (0)