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), Text (.txt), reStructuredText(.rst), Markdown (.md), Ruby (.ruby), 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

By default, on Linux and Mac systems, pyenchant uses GNU aspell as the underlying dictionary. The spell checking is case sensitive. While aspell allows arbitrary characters in a dictionary word, CSC may split up a word by non-alphanumeric characters. This split can occur if the word itself is not found in the dictionary.

If a dictionary word has non-alphanumeric characters, CSC prints a warning.

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.2.tar.gz (88.9 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.2-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: comment_spell_check-0.4.2.tar.gz
  • Upload date:
  • Size: 88.9 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.2.tar.gz
Algorithm Hash digest
SHA256 1a23c5444a9618427beae9771aaaf38c882d4ad3ae736da9a63284c3202e61ba
MD5 a27808f37ff825e3d495064547c1ed5c
BLAKE2b-256 4f26359067df93005c4cd437f831ef80df527e6b3eb74e2223b0a66c627a6f83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comment_spell_check-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b5da3ca6c763df40fb13f531e2359fae62b5f0726ac6ef7c816ae43e098491c1
MD5 19eac5d35607a73416f8b53bebc3842f
BLAKE2b-256 a7c826e16d5f8797ba8aad3377459de4146c21e034d136c1209764c4e11df2d1

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