• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python Library and CLI for the LanguageTool JSON API

pyLanguagetool

travis license Latest Version pypi_versions

A python library and CLI for the LanguageTool JSON API.

LanguageTool is an open source spellchecking platform. It supports a large variety of languages and has advanced grammar support.

https://pylanguagetool.lw1.at/_images/screenshot.png

Installation

pyLanguagetool can be installed with pip/pipenv:

pip install pylanguagetool
# or via pipenv
pipenv install pylanguagetool

Basic Usage

# pipe text to pylanguagetool
echo "This is a example" | pylanguagetool

# read text from a file
pylanguagetool textfile.txt

# read text from stdin
pylanguagetool < textfile.txt

# read text from the systems clipboard
pylanguagetool -c # get text from system clipboard

All samples above will return a list of detected errors and possible replacements.

# Use "an" instead of 'a' if the following word starts with a vowel sound, e.g. 'an article', 'an hour'
#   ✗ This is a example
#             ^
#   ✓ This is an example

Configuration

All LanguageTool API parameters can be set via command line arguments, environment variables or a configuration file (~/.config/pyLanguagetool.conf) For more information about the configuration file syntax, read the ConfigArgParse documentation.

Parameters

$ pylanguagetool --help
usage: pylanguagetool [-h] [-v] [-a API_URL] [--no-color] [-c] [-s]
                      [-t {txt,html,md,rst,ipynb}] [-l LANG]
                      [-m MOTHER_TONGUE] [-p PREFERRED_VARIANTS]
                      [-e ENABLED_RULES] [-d DISABLED_RULES]
                      [--enabled-categories ENABLED_CATEGORIES]
                      [--disabled-categories DISABLED_CATEGORIES]
                      [--enabled-only] [--pwl PWL]
                      [input file]

Args that start with '--' (eg. -v) can also be set in a config file
(~/.config/pyLanguagetool.conf). Config file syntax allows: key=value,
flag=true, stuff=[a,b,c] (for details, see syntax at
https://pypi.org/project/ConfigArgParse/). If an arg is specified in more than
one place, then commandline values override environment variables which
override config file values which override defaults.

positional arguments:
  input file            input file

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         [env var: VERBOSE]
  -a API_URL, --api-url API_URL
                        the URL of the v2 languagetool API, should end with
                        '/v2/' [env var: API_URL]
  --no-color            don't color output [env var: NO_COLOR]
  -c, --clipboard       get text from system clipboard [env var: CLIPBOARD]
  -s, --single-line     check every line on its own [env var: SINGLE_LINE]
  -t {txt,html,md,rst,ipynb}, --input-type {txt,html,md,rst,ipynb}
                        if not plaintext [env var: CLIPBOARD]
  -r, --rules           show the matching rules [env var: RULES]
  --rule-categories     show the the categories of the matching rules [env
                        var: RULE_CATEGORIES]
  -l LANG, --lang LANG  A language code like en or en-US, or auto to guess the
                        language automatically (see preferredVariants below).
                        For languages with variants (English, German,
                        Portuguese) spell checking will only be activated when
                        you specify the variant, e.g. en-GB instead of just
                        en. [env var: TEXTLANG]
  -m MOTHER_TONGUE, --mother-tongue MOTHER_TONGUE
                        A language code of the user's native language,
                        enabling false friends checks for some language pairs.
                        [env var: MOTHER__TONGUE]
  -p PREFERRED_VARIANTS, --preferred-variants PREFERRED_VARIANTS
                        Comma-separated list of preferred language variants.
                        The language detector used with language=auto can
                        detect e.g. English, but it cannot decide whether
                        British English or American English is used. Thus this
                        parameter can be used to specify the preferred
                        variants like en-GB and de-AT. Only available with
                        language=auto. [env var: PREFERRED_VARIANTS]
  -e ENABLED_RULES, --enabled-rules ENABLED_RULES
                        IDs of rules to be enabled, comma-separated [env var:
                        ENABLED_RULES]
  -d DISABLED_RULES, --disabled-rules DISABLED_RULES
                        IDs of rules to be disabled, comma-separated [env var:
                        DISABLED_RULES]
  --enabled-categories ENABLED_CATEGORIES
                        IDs of categories to be enabled, comma-separated [env
                        var: ENABLED_CATEGORIES]
  --disabled-categories DISABLED_CATEGORIES
                        IDs of categories to be disabled, comma-separated [env
                        var: DISABLED_CATEGORIES]
  --enabled-only        enable only the rules and categories whose IDs are
                        specified with --enabled-rules or --enabled-categories

  --pwl PWL, --personal-word-list PWL
                        File name of personal dictionary. A private dictionary
                        can be used to add special words that would otherwise
                        be marked as spelling errors. [env var:
                        PERSONAL_WORD_LIST]

Privacy

By default, pyLanguagetool sends all text via HTTPS to the LanguageTool server (see their privacy policy). You can also set up your own server and use it by changing the --api-url attribute.

More Repositories

1

voice_pack_dreame

A GLaDOS Voice Pack for Dreame Vaccum Robots generated using 15.ai
Python
45
star
2

rss2wallabag

Import RSS feeds to Wallabag
Python
32
star
3

se-simulator

Generating fun Stack Exchange questions using Markov chains
Python
25
star
4

BrachioGraph-Utils

A collection of random scripts for generating plots
Python
14
star
5

invoices

Quickly creating invoices with the power of LaTeX and Python
Python
5
star
6

jax-array-info

Debugging tool to print information (especially sharding) about jax arrays
Python
4
star
7

plugin-PasswordVerifier

PHP
3
star
8

MatomoLiteTracker

An experimental, much smaller alternative to matomo.js
TypeScript
3
star
9

RadioStats

Find the most played songs on Austrian radio
Python
3
star
10

plugin-ProfileAvatar

PHP
3
star
11

RainbowRoad

Mapping rainbow/pride flag zebra crossings in Austria
TypeScript
3
star
12

thumbhash-python

An experimental port of ThumbHash to Python
Python
2
star
13

matomo-ClassicTheme

You don't like bright colors? Then this theme brings back the old style of Matomo 3.6.0
CSS
2
star
14

plugin-ClassicCounter

PHP
2
star
15

matomo-DiagnosticsExtended

PHP
2
star
16

acronomy-krunner

Krunner plugin for Acronomy
Python
2
star
17

mask-detector

find websites using the mask Typo3 extension
JavaScript
2
star
18

plugin-QuickExcludeVisitorIP

PHP
2
star
19

RPGnotes

An experimental, collaborative note taking app and wiki optimized for RPG games.
Python
2
star
20

matomo-injector

Try out Matomo, the open source, privacy aware web analytics software, without the need to modify anything.
JavaScript
2
star
21

rebound-collisions

Test to add water-retention-interpolation to a rebound n-body integration
Python
2
star
22

lightpollution

CSS
1
star
23

matomo-darktheme

CSS
1
star
24

portal-arg-and-SSTV

Python scripts for decoding SSTV images used in the Portal ARG
Python
1
star
25

new-github-changelog-generator

Python
1
star
26

typo3-keyboard

JavaScript
1
star
27

rebound-stubs

Python
1
star
28

lw1.at

HTML
1
star
29

plugin-CustomiseTranslations

PHP
1
star
30

plugin-DevelopmentToogle

PHP
1
star
31

veranstaltung

Veranstaltungskalender mit PHP und MySQL
PHP
1
star
32

git-mirror

very simple git mirror
Python
1
star
33

rockstar-swift-input

C
1
star