Natural Language Toolkit

...software, data sets and tutorials for natural language processing...

Package Structure

 

From NLTK

Jump to: navigation, search

NLTK Packages conform to the following structure:

all modules
  • opening comment with package name, copyright, license, authors
__init__.py
  • package-level docstring
  • import statements that import module names (but not api or util) into the package namespace: from module import * (for all modules in the package)
  • define __all__
  • mappings from deprecated functions to current functions, with deprecation decorators
  • example: http://nltk.org/nltk/chunk/__init__.py
api.py
  • define any interface classes that are used in other modules
  • this should be imported into other modules
  • (this filename is misleading as it is not an external API)
  • example: http://nltk.org/nltk/chunk/api.py
util.py
module.py
  • imports in three blocks: standard library and third party imports, nltk imports, package-local imports
  • imports from this package are local imports, of the form from other_module import name (and not from nltk.package.other_module import name; to facilitate moving, splitting and merging of packages)
  • imports from other nltk packages are fully qualified, e.g. from nltk import tokenize.
Personal tools