Self-hosting LanguageTool

Summary

LanguageTool is a free online proofreading service for English, Spanish, and 20 other languages. Instantly check your text for grammar and style mistakes. It’s a free alternative to similar sites/services like Grammarly. While I’m not sure that Grammarly is a Privacy Nightmare, I don’t like the idea of sending everything I write to a third party service for inspection.

The free version of LanguageTool has a much better reputation, although that may be because it’s less well-known. It’s also nice that it’s an open-source project that publishes the code.

Best yet – with a bit of work, you can self-host the basic functionality of LanguageTool and prevent anything from being sent anywhere outside your control.

I’ve Installed LanguageTool in Docker via portainer with persistent data saved on the local disk. I am using Nginx Proxy Manager to proxy access to this stack from the outside world

Installation

Optional – n-gram data

LanguageTool can make use of large n-gram data sets to detect errors with words that are often confused, like their and there. The n-gram data set is huge and thus not part of the LT download. To make use of it, you need to create a directory to hold the (huge – 8 GB!) persistent data. I am using a directory on the physical disk mounted at /mnt/data1/languagetool

mkdir /mnt/data1/languagetool

Then download and unzip the n-gram data zip file into the languagetool directory.

docker-compose.yml

version: "3"

services:
  languagetool:
    image: erikvl87/languagetool
    container_name: languagetool
    ports:
        - 8010:8010  # Using default port from the image
    environment:
        - langtool_languageModel=/ngrams  # OPTIONAL: Using ngrams data
        - Java_Xms=512m  # OPTIONAL: Setting a minimal Java heap size of 512 mib
        - Java_Xmx=1g  # OPTIONAL: Setting a maximum Java heap size of 1 Gib
    volumes:
        - /mnt/data1/languagetool:/ngrams

Usage

Firefox / Brave (probably Chrome)

  • Install the Firefox extension or the Chrome extension
  • Click on the LT extension icon in the toolbar and go to Settings (the cog wheel).
  • Under Advanced settings (only for professional users), set LanguageTool Server to Other server – requires LanguageTool server running there , and enter your server address.
  • Remember to append the /v2 to the end of the URL.  Ex. https://languagetool.example.com/v2
  • Note: if you run Firefox sync, this configuration is not synced.  In other words, you have to add your custom server to each instance of Firefox.

Reference

Leave a Comment