DEV Community

a2n
a2n

Posted on

Using LanguageTool locally

Since LanguageTool has put their correction tool behind a "not so free" plan (for good reason) I wanted to use a local one (also for good reason).

Find out that this is a pretty simple process, so let's do it :)

The prerequisite are quite simple: we need docker, and docker compose.

I consider that you know how to install that on your machine.

First we need to get the n-gram data from the LanguageTool server (https://languagetool.org/download/ngram-data/). There are pretty heavy files but help the model we're going to set up to be more performant.

You can dl the one you want and put in the folder of the project, for example: ~/.languagetool/ngrams.

In the past version of the docker image were going to use we normally have to use Fasttext from facebook, but it is now included by default.

The last step is to create the actual docker-compose file (docker-compose.yml):

services:
  languagetool:
    image: erikvl87/languagetool:latest
    container_name: languagetool
    restart: always
    tmpfs:
      - /tmp:exec
    cap_drop:
      - ALL
    cap_add:
      - CAP_SETUID
      - CAP_SETGID
      - CAP_CHOWN
    security_opt:
      - no-new-privileges
    ports:
      - 8010:8010
    environment:
      - langtool_languageModel=/ngrams   # OPTIONAL: Using ngrams data
      - Java_Xms=512m                    # OPTIONAL: Setting a minimal Java heap size of 512 mib
      - Java_Xmx=3g
    volumes:
      - ./ngrams:/ngrams
Enter fullscreen mode Exit fullscreen mode

You can edit the port if needed of course, with this file setup you can now run this docker (docker compose up) and then go to your LanguageTool browser extension settings and search for "Advanced settings (only for professional users)".

In this section you have to check "Other server—requires LanguageTool server running there" and use this URL http://localhost:8010/v2.

And voilà this is simple has that :)

Top comments (0)