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 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.
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
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
Built Distribution
Hashes for qporcupine-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6d9a2708305600fb51105d2083195f7811d3b44ff197b265625d359ed3ec087 |
|
MD5 | 4b598c32e2f1ae7022969111b01b2c4c |
|
BLAKE2b-256 | f8bfe11f5adf0ac3ddcc47797862d9cf9f65dbb436bdd615152c4858ff442469 |