tLangTool - free offline command line grammar check

Check your English grammar offline, from command line.

Download the latest tlangtool. Free software under the GPL.

TLangTool is a CLI wrapper for LanguageTool HTTP API. Offline functionality requires local LanguageTool server.

Usage Example

$ tlangtool tero.txt 
L1:43 B257      REDUNDANCY: Specify a number, remove phrase [..]
"...es and use of new versions of software, a large number of [..]
                                            ^^^^^^^^^^^^^^^^^

TLangTool shows

  • Line number and column (L1:43)
  • Byte offset from the start of file (B257)
  • Rule category ID (REDUNDANCY)
  • The advice (Specify a number...)

And

  • Highlights the mistake

When --machine readable one-line output is enabled, highlighted sentence is not included.

Download (GPL 2)

Download the latest tlangtool.

It's a single file Python program, so

$ wget https://terokarvinen.com/2022/tlangtool-command-line-grammar-check/tlangtool
$ chmod a+x tlangtool
$ echo "Seee you at TeroKarvinen.com"|./tlangtool --api https://api.languagetool.org/v2/check -
	L0:0 B0 TYPOS: Possible spelling mistake found. (See, Seen, Sees, Seed, Seek)
	"Seee you at TeroKarvinen.com "

Help

$ tlangtool --help
usage: tlangtool [-h] [-v] [-d] [--api API] [--disabled-rules DISABLED_RULES]
                 [--language LANGUAGE] [-m] [--with-file-name]
                 file

positional arguments:
  file                  Input file. Use dash "-" for standard input

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose
  -d, --debug
  --api API             URL of LanguageTool HTTP API, use --api
                        https://api.languagetool.org/v2/check for LanguageTool
                        public API
  --disabled-rules DISABLED_RULES
                        IDs of disabled rules, as defined in LanguageTool API
                        docs https://languagetool.org/http-api/swagger-
                        ui/#!/default/post_check
  --language LANGUAGE
  -m, --machine         Output one thing per line machine readable output
  --with-file-name      Print file name on each line

Grammar check file using LanguageTool HTTP API, local or remote

- Grammar check files from command line
- Completely offline when used with local LanguageTool server
- Free software (GPL 2), using LanguageTool under the LGPL-2.1 License 

Installing local offline LanguageTool server

$ sudo docker pull erikvl87/languagetool
$ sudo docker run --detach --rm -p 8010:8010 erikvl87/languagetool

Usage

$ echo 'See you at TeroKarvinen.com. Car drivinggg.'|tlangtool -
L0:33 B33       TYPOS: Possible spelling mistake found. (driving, drivings)
"See you at TeroKarvinen.com. Car drivinggg. "
                                  ^^^^^^^^^
$ tlangtool sample.txt 

Using a Public Online LanguageTool.org Instance

Use of public API is subject to terms and restrictions https://dev.languagetool.org/public-http-api.html

$ echo "Seee you at TeroKarvinen.com"|tlangtool --api https://api.languagetool.org/v2/check -
L0:0 B0 TYPOS: Possible spelling mistake found. (See, Seen, Sees, Seed, Seek)
"Seee you at TeroKarvinen.com "
 ^^^^

Copyright 2022 Tero Karvinen http://TeroKarvinen.com , GNU General Public License 2

Prior work

Lukas Winkler has created pyLanguagetool. I needed to automatically perform grammar check without human intervention, but could not get pyLangtool to work in a pipeline. It worked nice when output was to a tty, but with pipe and file pipe output I got the error "UnicodeEncodeError: 'ascii' codec can't encode character". pyLanguagetool generates pretty colored output, which tlangtool 0.2.0 can't do.

Many interfaces to LanguageTool exist, and are listed in LanguageTool Wiki.

tLangTool is not based on any earlier work. LanguageTool has very simple HTTP API, so writing a CLI wrapper from scratch might be easier than figuring out someone else's code.

FAQ

Are you going to spellchecking this pages grammar? Maybe later.

Where can I download it? Download the latest tlangtool.