Utility Methods

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

Module Imports

chatterbot.utils.import_module(dotted_path)[source]

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

Terminal input

chatterbot.utils.input_function()[source]

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

chatterbot.utils.nltk_download_corpus(resource_path)[source]

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, 4, 25, 7, 41, 32, 980834))[source]

Extract datetime objects from a string of text.