Skip to main content

Grammar error detection and feedback

Project description

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 Pattern for Python 3

One of qporcupine's dependencies is a development branch of the Pattern.en library, which is not available through PyPi. Consequently, qporcupine must be directly installed from its Github repo. This can be done with the command

$ pip install git+git://github.com/clips/pattern.git@53245196139c6ef26dc9c34873dda8a16f236d23#egg=Pattern

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.

4. Install qporcupine

pip install qporcupine

5. Configure Spacy Language Model

qporcupine uses the en_core_web_lg Spacy model by default. To configure this model, you may have to download the en_core_web_lg model from Spacy by running:

python -m spacy download en_core_web_lg

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 .

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

qporcupine-0.0.4-py2.py3-none-any.whl (15.3 MB view hashes)

Uploaded Python 2 Python 3

Supported by

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