Skip to content

This set of scripts will parse text and provide suggestions for spelling and grammatical corrections. The scripts may be used on the command line with verbose console output, or to produce JSON formatted output.

Notifications You must be signed in to change notification settings

ian-james/lang_tools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Language Tools

This set of scripts will parse text and provide suggestions for spelling and grammatical corrections. The scripts may be used on the command line with verbose console output, or to produce JSON formatted output.

These scripts are intended to be merged into the Immediate Feeback System as part of the core tools.

Prequisites

Python Hunspell

The spell check script makes use of Hunspell dictionaries and correction.

$ sudo apt install hunspell

You also need the python wrapper:

$ sudo -H pip install hunspell

Language Tool

Install LanguageTool and its python wrapper by:

$ sudo -H pip install --upgrade 3to2
$ sudo -H pip install --upgrade language-check

Usage

spell_check.py

Run check on a file called misspellings against Canadian English dictionaries with output to the console. If the --lang or short -l option isn't specified, then the default language that is used is Canadian English.

spell_check.py --lang=en_CA -i mispellings

Run check on a file called misspellings against US English dictionaries, with output to corrections.json.

spell_check.py --lang=en_US --json=corrections.json --ifile=mispellings
spell_check.py -l en_US -j corrections.json -i misspellings

Note that if Hunspell is not installed at the default path /usr/share/hunspell, then you may specify the path with either the -p or the --path option.

For instance:

spell_check.py --path=/opt/hunspell --ifile=misspellings
spell_check.py -p /opt/hunspell -i misspellings

By default the list of correctly spelled words is suppressed from the output, however this can be revealed by specifying either the -c or --correct option.

spell_check.py --correct --ifile=misspellings
spell_check.py -c -i misspellings

For help:

spell_check.py --help

grammar.py

Run check on a file called bad_grammar against Canadian English rules with output to the console. If the --lang option isn't specified, then the default language rules that are used belong to Canadian English.

grammar.py --lang=en_CA --ifile bad_grammar
grammar.py -l -i bad_grammar

Run check on a file called bad_grammar against US English rules, with output to grammatical.json.

grammar.py --lang=en_US --json=grammatical.json --ifile bad_grammar
grammar.py -l en_US -j grammatical.json -i bad_grammar

For help:

grammar.py --help

Caveats

spell_check.py

By nature of the engine, hyphenated compound words that are correct on each side of the hyphen will pass the spellcheck even if the compound is not in the given language's lexicon. Ex. "cat-dog" is not an English word, but will pass.

grammar.py

Kind of slow?

License Information

These scripts are free software, and are licensed permissively under the ISC License. See the comment headers of each script for additional information.

See also the license information attached to the libraries that were used for this project.

About

This set of scripts will parse text and provide suggestions for spelling and grammatical corrections. The scripts may be used on the command line with verbose console output, or to produce JSON formatted output.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%