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.

Class initialization

chatterbot.utils.initialize_class(data, *args, **kwargs)[source]
Parameters:data – A string or dictionary containing a import_path attribute.

NLTK corpus downloader


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

Returns True if the corpus needed to be downloaded.

ChatBot response time

chatterbot.utils.get_response_time(chatbot, statement='Hello')[source]

Returns the amount of time taken for a given chat bot to return a response.

Parameters:chatbot (ChatBot) – A chat bot instance.
Returns:The response time in seconds.
Return type:float

Parsing datetime information

chatterbot.parsing.datetime_parsing(text, base_date=datetime.datetime(2019, 2, 14, 10, 46, 49, 611923))[source]

Extract datetime objects from a string of text.