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.

Class initialization

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

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.

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, 45, 40, 941220))[source]

Extract datetime objects from a string of text.