Skip to main content

A script to automatically spell checks comments of a codebase.

Project description

CommentSpellCheck

python testing

The CommentSpellCheck (CSC) package provides a script that automatically spell checks the comments of a code base. It was originally developed to be run on the SimpleITK and ITK code bases.

Here is how it is typically run:

python comment_spell_check.py --exclude Ancillary $SIMPLEITK_SOURCE_DIR/Code

This command will recursively find all the '.h' files in a directory, extract the C/C++ comments from the code, and run a spell checker on them. The '--exclude' flag tells the script to ignore any file that has 'Ancillary' in its full path name. This flag will accept any regular expression.

In addition to pyenchant's English dictionary, we use the words in additional_dictionary.txt. These words are proper names and technical terms harvest by hand from the SimpleITK and ITK code bases.

If a word is not found in the dictionaries, we try two additional checks.

  1. If the word starts with some known prefix, the prefix is removed ...and the remaining word is checked against the dictionary. The prefixes ...used by default are 'sitk', 'itk', and 'vtk'. Additional ...prefixes can be specified with the '--prefix' command line argument.

  2. We attempt to split the word by capitalization and check each ...sub-word against the dictionary. This method is an attempt to detect ...camel-case words such as 'GetArrayFromImage', which would get split into ...'Get', 'Array', 'From', and 'Image'. Camel-case words are very commonly ...used for code elements.

The script can also process other file types. With the '--suffix' option, the following file types are available: Python (.py), C/C++ (.c/.cxx), CSharp (.cs), Text (.txt), reStructuredText(.rst), Markdown (.md), Ruby (.ruby), R (.R), and Java (.java). Note that reStructuredText files are treated as standard text. Consequentially, all markup keywords that are not actual words will need to be added to the additional/exception dictionary.

Dictionary notes

We use PySpellChecker as the underlying spellchecker and its associated default dictionary. Previously we used the pyenchant package and its default dictionary. The pyenchant package requires an underlying C library, which is not available on all platforms. PySpellChecker is a pure Python package and works on all platforms with no additional dependencies.

Project details


Download files

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

Source Distribution

comment_spell_check-0.4.3.tar.gz (89.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comment_spell_check-0.4.3-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file comment_spell_check-0.4.3.tar.gz.

File metadata

  • Download URL: comment_spell_check-0.4.3.tar.gz
  • Upload date:
  • Size: 89.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for comment_spell_check-0.4.3.tar.gz
Algorithm Hash digest
SHA256 17af6081ce6d5e67134d1e767ee81dcd295c1ad2b65c21242506bfcd696ad9e3
MD5 8c58ec1e0cebff0250375a97c750d3a6
BLAKE2b-256 8f8ada1f043429d852ccec778270e263db207978a0f8d755f123b1e72e4037ae

See more details on using hashes here.

File details

Details for the file comment_spell_check-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for comment_spell_check-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cc835d908537f27a7234da02064f50971d910a8c3434697ee620b7dc495f7b44
MD5 b1aceef848ef0a94e0e7608a3ea2aa7b
BLAKE2b-256 d56882ad6871397a4b0ebfb0a24065b28812ba9563d74b0ebaa258e375746300

See more details on using hashes here.

Supported by

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