{"id":17149820,"url":"https://github.com/keeferrourke/lang_tools","last_synced_at":"2025-03-24T11:43:24.828Z","repository":{"id":72115359,"uuid":"81166773","full_name":"keeferrourke/lang_tools","owner":"keeferrourke","description":"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 english output, or to produce JSON formatted output to stdout or a file.","archived":false,"fork":false,"pushed_at":"2017-05-24T23:50:38.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T17:11:28.374Z","etag":null,"topics":["grammar-checker","hunspell","json-data","language","languagetool","python","spell-check"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keeferrourke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-07T04:36:46.000Z","updated_at":"2024-09-26T13:34:45.000Z","dependencies_parsed_at":"2023-04-20T19:17:36.273Z","dependency_job_id":null,"html_url":"https://github.com/keeferrourke/lang_tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keeferrourke%2Flang_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keeferrourke%2Flang_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keeferrourke%2Flang_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keeferrourke%2Flang_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keeferrourke","download_url":"https://codeload.github.com/keeferrourke/lang_tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245266937,"owners_count":20587452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grammar-checker","hunspell","json-data","language","languagetool","python","spell-check"],"created_at":"2024-10-14T21:34:11.607Z","updated_at":"2025-03-24T11:43:24.820Z","avatar_url":"https://github.com/keeferrourke.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Language Tools\n\nThis set of scripts will parse text and provide suggestions for spelling\nand grammatical corrections. The scripts may be used on the command line with\nverbose console output, or to produce JSON formatted output.\n\nThese scripts have been merged into the\n[_Immediate Feedback System_](https://github.com/ian-james/IFS) as part of the\ncore tools.\n\n![IFS integration](https://krourke.org/img/lang_tools.png)\n\n## Notes\nThere are now two versions of each utility, one for python2 environments, and\none for python3 environments. They accomplish the exact same task, in the\nexact same fashion. A python3 rewrite was required for compatibility with\nIFS however.\n\n## Prequisites\n\n#### Python Hunspell\nThe spell check script makes use of Hunspell dictionaries and correction.\n```sh\n$ sudo apt install hunspell libhunspell-dev\n```\n\nYou also need the python wrapper:\n```sh\n$ sudo -H pip install hunspell\n```\n\n#### Language Tool\nInstall LanguageTool and its python wrapper by:\n```sh\n$ sudo -H pip install --upgrade 3to2\n$ sudo -H pip install --upgrade language-check\n```\n\n## Usage\n\n### spell\\_check.py\n\nRun check on a file called `misspellings` against Canadian English\ndictionaries with JSON output to the console. If the `--lang` or short `-l`\noption isn't specified, then the default language that is used is Canadian\nEnglish.\n```sh\nspell_check.py --lang=en_CA -i mispellings\n```\n\nRun check on a file called `misspellings` against US English dictionaries,\nwith output to `corrections.json`.\n```sh\nspell_check.py --lang=en_US --outfile=corrections.json --infile=mispellings\nspell_check.py -l en_US -o corrections.json -i misspellings\n```\n\nNote that if Hunspell is not installed at the default path\n`/usr/share/hunspell`, then you may specify the path with either the `-p` or\nthe  `--path` option.\n\nFor instance:\n```sh\nspell_check.py --path=/opt/hunspell --infile=misspellings\nspell_check.py -p /opt/hunspell -i misspellings\n```\n\nBy default the list of correctly spelled words is suppressed from the output,\nhowever this can be revealed by specifying either the `-c` or `--correct`\noption.\n```sh\nspell_check.py --correct --ifile=misspellings\nspell_check.py -c -i misspellings\n```\n\nFor alternative, simplified plain English output, pass the `--english` flag.\n\nTo suppress output to console when an output file is specified, pass either\n`-q` or `--quiet`.\n\nFor help:\n```sh\nspell_check.py --help\n```\n\n### grammar.py\n\nRun check on a file called `bad_grammar` against Canadian English rules with\nJSON output to the console. If the `--lang` option isn't specified, then the\ndefault language rules that are used belong to Canadian English.\n```sh\ngrammar.py --lang=en_CA --infile bad_grammar\ngrammar.py -l en_CA -i bad_grammar\n```\n\nRun check on a file called `bad_grammar` against US English rules, with output\nto `grammatical.json`.\n```sh\ngrammar.py --lang=en_US --outfile=grammatical.json --infile bad_grammar\ngrammar.py -l en_US -o grammatical.json -i bad_grammar\n```\n\nInclude spell checking with the grammar check:\n```sh\ngrammar.py --infile bad_grammar --with_spelling\ngrammar.py -i --with_spelling\n```\n\nFor alternative, simplified plain English output, pass the `--english` flag.\n\nTo suppress output to console when an output file is specified, pass either\n`-q` or `--quiet`.\n\nFor help:\n```sh\ngrammar.py --help\n```\n\n### Output\nThese scripts will print JSON containing feedback objects, as specified in the\n[IFS Wiki](https://github.com/ian-james/IFS/wiki).\n\nSpell checking JSON output is as follows:\n\n```javascript\n{\n    \"feedback\" : [\n        {\n            \"target\": \"received\",\n            \"wordNum\": 40,\n            \"lineNum\": 2,\n            \"linePos\": 12,\n            \"charPos\": 89,\n            \"type\": \"spelling\",\n            \"lang\": \"en_CA\",\n            \"toolName\": \"hunspell\",\n            \"filename\": \"infile.txt\",\n            \"feedback\": \"Selected word not found in en_CA dictionary\",\n            \"suggestions\": [\n                \"recieved\",\n                \"recieves\"\n            ]\n        }\n    ]\n}\n\n```\n\nGrammar checking JSON output is as follows, where the `hl_begin` and `hl_end`\nattributes specify the (character on line, line) positions where the error\nbegins, and the error ends.\n\n```javascript\n{\n    \"feedback\" : [\n        {\n            \"target\": \"...context of the error...\",\n            \"hl_begin\": [\n                20,\n                2\n            ],\n            \"hl_end\": [\n                12,\n                3\n            ],\n            \"lang\": \"en_CA\",\n            \"type\": \"type of grammar rule that was violated\",\n            \"toolName\": \"Language Tool\",\n            \"filename\": \"infile.txt\",\n            \"feedback\": \"Language Tool feedback message\",\n            \"suggestions\": [\n                \"replacement suggestion 1\",\n                \"replacement suggestion 2\",\n                \"replacement suggestion 3\"\n            ]\n        }\n    ]\n}\n\n```\n\n## Caveats\n\n### spell\\_check.py\n\nBy nature of the engine, hyphenated compound words that are correct on each\nside of the hyphen will pass the spellcheck even if the compound is not in the\ngiven language's lexicon. Ex. \"cat-dog\" is not an English word, but will pass.\n\n### grammar.py\n\nKind of slow, maybe?\n\n## License Information\n\nThese scripts are\n[free software](https://www.gnu.org/philosophy/free-sw.en.html), and are\nlicensed permissively under the ISC License. See the comment headers of each\nscript for additional information.\n\nSee also the license information attached to the libraries that were used for\nthis project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeeferrourke%2Flang_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeeferrourke%2Flang_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeeferrourke%2Flang_tools/lists"}