Jump to content

LanguageTool

From ArchWiki


LanguageTool is an open-source grammar checker that is marketed with a freemium model. The paid version offers a separate API endpoint with additional rules. This article explains how to run it locally.

Installation

Install languagetool and start/enable the languagetool.service.

Usage

To see if it works, run:

# curl -s -d "language=en-US" -d "text=This are a test. He edit the wiki yesterday." http://localhost:8081/v2/check | jq -r '.matches[] | "\(.rule.id): \(.message)"'

Supported applications

Configuration

Use systemctl edit to add a configuration file to the languagetool.service:

/etc/systemd/system/languagetool.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/languagetool --http --port 8081 --allow-origin "*" --config /etc/languagetool/server.properties

FastText

Optional, but recommended are fasttextAUR and fasttext-langid-modelsAUR for language detection:

/etc/languagetool/server.properties
fasttextModel=/usr/share/fastext/lid.176.bin
fasttextBinary=/usr/bin/fasttext

N-gram

The tool can use N-gram data sets to improve the grammar detection at the expense of memory usage.

Install the languages you are interested in:

Then, edit the configuration file, adding:

/etc/languagetool/server.properties
languageModel=/usr/share/ngrams/

See also