Skip to main content

QPorcupine

A library from Quill.org to provide feedback on common grammar errors. Errors detected include spelling errors, fragments, and subject-verb agreement errors.

Note: This library is currently unstable; please be aware that updates could include breaking changes.

Usage

As a module:

from qporcupine import check

feedback  = check('Until she leapt into the air and kissed him.')
print(feedback.human_readable)

Expected output:

This looks like a subordinating conjunction fragment.
Try removing the subordinating conjunction or adding a main clause.

Installation

1. Install languagetool

qporcupine relies on LanguageTool to function. LanguageTool is an open-source grammar and spell-checker written in Java. In order to maximize performance, we will run a languagetool server that qporcupine will be able to connect to.

Change to the opt directory. If you don't have one, create one with $ sudo mkdir /opt.

$ cd /opt

Download and unzip languagetool.

$ sudo curl -O "https://languagetool.org/download/LanguageTool-4.1.zip"
$ sudo unzip LanguageTool-4.1.zip
$ sudo rm LanguageTool-4.1.zip

Add the follwing lines to your .bash_profile or system equivalent. Do not include a trailing slash for the LT_URI.

alias ltserver='nohup java -cp /opt/LanguageTool-4.1/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081 </dev/null >/dev/null 2>&1 &'
export LT_URI=http://localhost:8081

Start the server

$ ltserver

LanguageTool is now running on port 8081. To test that it works try hitting http://localhost:8081/v2/check?language=en-US&text=my+text in your browser.

2. Download the AllenNLP Constituency Parser

qporcupine uses the AllenNLP library, a suite of open-source natural-language processing tools developed by the Allen Institute for Artificial Intelligence. Specifically, qporcupine uses the constituency parse model from AllenNLP.

We store the AllenNLP model in /var/lib/allennlp. To configure this folder and download the model for use, run:

$ sudo mkdir /var/lib/allennlp
$ cd /var/lib/allennlp && { sudo curl -O https://s3-us-west-2.amazonaws.com/allennlp/models/elmo-constituency-parser-2018.03.14.tar.gz; cd -;}

3. Install qporcupine

One of qporcupine's dependencies is a development branch of the Pattern.en library, which is not available through PyPi. Consequently, qporcupine must be installed with the --process-dependency-links flag, which will install the necessary dependency.

In some cases, there may be conflicts between this installation of the Pattern library and existing installations of Pattern on your local machine. If so, we suggest uninstalling Pattern and attempting to install qporcupine again. You may also need the --no-cache-dir flag for pip install.

pip install --process-dependency-links qporcupine

4. Configure Spacy Language Model (Optional)

qporcupine uses the en_core_web_lg Spacy model by default. If you wish to download and configure another model, do so with

python -m spacy download <SPACY MODEL NAME>

and set

export QUILL_SPACY_MODEL=<SPACY_MODEL_NAME>

Tests

QPorcupine uses nose to run tests. To run tests from the root directory of qporcupine:

$ pip install nose
$ nosetests

Version Support

Please note that QPorcupine does not currently support Python 3.7. We suggest using Python 3.6.x .

Metadata

Release files for qporcupine 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for qporcupine 0.0.3
File Interpreter ABI Platform
qporcupine-0.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / qporcupine-0.0.3-py2.py3-none-any.whl

Download URL qporcupine-0.0.3-py2.py3-none-any.whl
Size 15.3 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6b9a758d8d5319ca2d61ba8231cbc35e73355ea2d8a8593f369a6490e7f7e739
BLAKE2b-256 checksum
How to use checksums
389f60cd608ae38ee302ac32e20954856c67894f13eb8d117ecab81789747e78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

Release history Release notifications | RSS feed

0.0.4

1 release file

This release

0.0.3 This release

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page