What do we say to typos? Not today!
Tags: writing, docker, productivity, opensource
Published: 2022-04-20 17:55:14

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](https://languagetool.org/de).   
Therefore, I looked around on GitHub for a way of hosting my own LanguageTool server. 
I came across [this repository](https://github.com/Erikvl87/docker-languagetool) 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](https://chrome.google.com/webstore/detail/grammar-spell-checker-%E2%80%94-l/oldceeleldhonbafppcapldpdifcinji).
Head to the setting and set to URL to your LanguageTool Server:  
![LanguageTool configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4sevpd1ozfrtruq025c.png)
 
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:  
![LanguageTool integration dev.to](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7z6sql4g04cdwnwn3ujx.png)

Additional plugins can be found [here](https://languagetool.org/de).  

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

{% embed https://dev.to/tobhai %}

Header image by [Patrick Fore](https://unsplash.com/@patrickian4?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)