• Stars
    star
    326
  • Rank 129,027 (Top 3 %)
  • Language
    Python
  • License
    GNU Lesser Genera...
  • Created over 11 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

Python wrapper for LanguageTool grammar checker

language-check

Python wrapper for LanguageTool.

Build status

This is a fork of https://bitbucket.org/spirit/language_tool that produces more easily parsable results from the command-line.

Example usage

From the interpreter:

>>> import language_check
>>> tool = language_check.LanguageTool('en-US')
>>> text = u'A sentence with a error in the Hitchhiker’s Guide tot he Galaxy'
>>> matches = tool.check(text)
>>> len(matches)
2

Check out some Match object attributes:

>>> matches[0].fromy, matches[0].fromx
(0, 16)
>>> matches[0].ruleId, matches[0].replacements
('EN_A_VS_AN', ['an'])
>>> matches[1].fromy, matches[1].fromx
(0, 50)
>>> matches[1].ruleId, matches[1].replacements
('TOT_HE', ['to the'])

Print a Match object:

>>> print(matches[1])
Line 1, column 51, Rule ID: TOT_HE[1]
Message: Did you mean 'to the'?
Suggestion: to the
...

Automatically apply suggestions to the text:

>>> language_check.correct(text, matches)
'A sentence with an error in the Hitchhiker’s Guide to the Galaxy'

From the command line:

$ echo 'This are bad.' > example.txt

$ language-check example.txt
example.txt:1:1: THIS_NNS[3]: Did you mean 'these'?

Installation

To install via pip:

$ pip install --upgrade language-check

If you are using Python 2, you'll need to install 3to2 beforehand:

$ pip install --upgrade 3to2

To overwrite the host part of URL that is used to download LanguageTool-{version}.zip:

- SET LANGUAGE_CHECK_DOWNLOAD_HOST = [alternate URL]

Prerequisites

The installation process should take care of downloading LanguageTool (it may take a few minutes). Otherwise, you can manually download LanguageTool-stable.zip and unzip it into where the language_check package resides.

Vim plugin

To use language-check in Vim, install Syntastic and use the following settings:

let g:syntastic_text_checkers = ['language_check']
let g:syntastic_text_language_check_args = '--language=en-US'

Customize your language as appropriate.

More Repositories

1

cppclean

Finds problems in C++ source that slow development of large code bases
Python
694
star
2

perceptualdiff

A program that compares two images using a perceptually based image metric
C++
161
star
3

pyformat

Formats Python code to follow a consistent style
Python
94
star
4

unify

Modifies strings to all use the same quote where possible
Python
94
star
5

scspell

Spell checker for source code
Python
88
star
6

syntastic-extras

Additional Syntastic syntax checkers and features (for Vim)
Vim Script
29
star
7

vulture

Obsolete fork; instead see https://github.com/jendrikseipp/vulture
Python
27
star
8

cronometer

Nutrition tracker; fork of the old Java-based Cronometer with better macOS support and newer USDA database
Java
26
star
9

optparse

C++ implementation of optparse (header-only fork of https://github.com/weisslj/cpp-optparse)
C++
25
star
10

pyfuzz

Random program generator for Python
Python
10
star
11

pydiff

Diffs Python code at the bytecode level
Python
10
star
12

untokenize

Transforms tokens into original source code (while preserving whitespace)
Python
9
star
13

indent-finder

Vim plugin for detecting indentation of source code (fork of IndentFinder with Python 2 and 3 support)
C
8
star
14

pen

Unofficial fork of the pen TCP/UDP load balancer (and reverse proxy) tool
C
7
star
15

cram

Testing framework for command-line applications
Python
7
star
16

image-view

Displays images (PNM, PNG, JPEG, etc.) conveniently from the terminal
Python
6
star
17

pygame

Fork of pygame without X11 crud on OS X
C
4
star
18

unreferenced

Reports unreferenced files (as candidates for removal)
Python
4
star
19

trim

Trims trailing whitespace from files
Python
3
star
20

docgrep

Like grep, but only searches through docstrings (in Python files)
Python
3
star
21

move

Moves revision-controlled files interactively in an editor
Python
3
star
22

rst2pptx

Converts reStructuredText to PowerPoint
Python
2
star