Skip to main content

A python library and CLI for the LanguageTool JSON API

Project description

travis license Latest Version pypi_versions

This is a python library and CLI for the LanguageTool JSON API.

Installation

pyLanguagetool can be installed with pip:

$ pip install pylanguagetool

Basic Usage

$ echo "This is a example" | pylanguagetool

$ pylanguagetool textfile.txt

$ pylanguagetool < textfile.txt

This 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 commandline 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] [-l LANG] [-m MOTHER_TONGUE]
                    [-p PREFERRED_VARIANTS] [-e ENABLED_RULES]
                    [-d DISABLED_RULES]
                    [--enabled-categories ENABLED_CATEGORIES]
                    [--disabled-categories DISABLED_CATEGORIES]
                    [--enabled-only]
                    [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://goo.gl/R74nmi).
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
                        [env var: API_URL]
  --no-color            don't color output [env var: NO_COLOR]
  -c, --clipboard       get text from system clipboard [env var: CLIPBOARD]
  -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

Privacy

By default pyLangugagetool sends all text via HTTPS to the languagetool.org server (see their privacy policy). You can also setup your own server and use it by changing –api-url.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyLanguagetool-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyLanguagetool-0.2.0-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyLanguagetool-0.2.0.tar.gz.

File metadata

File hashes

Hashes for pyLanguagetool-0.2.0.tar.gz
Algorithm Hash digest
SHA256 39dc1789adc23d461e192577056c35dca81e6f824b927a60a4d72c065778dc7c
MD5 4e9e65fe1e9ac89831021ddc8b614d3d
BLAKE2b-256 0e4a63ccc6e37b6e76181a1e918f338560e27e6800b08eea3f18a9362874bdf5

See more details on using hashes here.

File details

Details for the file pyLanguagetool-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyLanguagetool-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 34e6b8adbe1e40745764e9934bbed93d0c2bbaa4a3e0ad66551134ca8d3a70cf
MD5 3883b29f88e0b99c24b413df9a809900
BLAKE2b-256 75855eeed26ebf73b121591dabe8faa7557d79953a562badb15e25b4b8a7de27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page