Utility Methods

ChatterBot has a utility module that contains a collection of miscellaneous but useful functions.

Module Imports


Imports the specified module based on the dot notated import path for the module.

Terminal input


Normalizes reading input between python 2 and 3. The function ‘raw_input’ becomes ‘input’ in Python 3.

Stopword removal

chatterbot.utils.remove_stopwords(tokens, language)[source]

Takes a language (i.e. ‘english’), and a set of word tokens. Returns the tokenized text with any stopwords removed. Stop words are words like “is, the, a, ...”

NLTK corpus downloader


Download the specified NLTK corpus file unless it has already been downloaded.

Returns True if the corpus needed to be downloaded.

Parsing datetime information

chatterbot.parsing.datetime_parsing(text, base_date=datetime.datetime(2017, 5, 2, 18, 8, 27, 173366))[source]

Extract datetime objects from a string of text.