What do we say to typos? Not today!
Tobias Haindl
Posted on April 20, 2022
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:
wget https://languagetool.org/download/ngram-data/ngrams-en-20150817.zip
To unpack the downloaded zip file into the directory ngrams
:
unzip ngrams-en-20150817.zip -d ngrams
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:
ngrams/en/1grams
ngrams/en/2grams
ngrams/en/3grams
ngrams/de/1grams
ngrams/de/2grams
ngrams/de/3grams
Pull and run the image
docker pull erikvl87/languagetool
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
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:
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 https://my-domain.dev
the configured URL should be https:/my-domain.dev/v2
.
After that the LanguageTool should be available to you.
In the dev.to
editor it looks like this:
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
Posted on April 20, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.