botify package¶
Module contents¶
-
class
botify.
Botify
(is_token_data_callback=None, clean_data_callback=None)[source]¶ Bases:
object
Framework for creating tools which perform various tasks based on natural language.
This framework enables developers to create a mapping between a natural language and user defined functions. This technique can then be used to create a tool which carries out certain tasks.
-
StrictModeEnabled
¶ bool – whether strict mode is enabled(Default True).
Parameters: - is_token_data_callback (function) –
A function to determine whether a string token is a valid data.
The function should take a single parameter as input and return True or False based on whether the token recieved is a valid data. data is defined as a token which yields information which needs to be passed to one of the defined tasks.
- clean_data_callback (function) – A function to perform any modification prior to passing the string token to the appropriate task. This callback if specified, will be used to generate the parameters which are to be passed to the tasks.
-
ACTION_DELETE
= 'delete'¶
-
ACTION_UPDATE_CONTEXT
= 'update_context'¶
-
ACTION_UPDATE_RULE
= 'update_rule'¶
-
add_modifier
(modifier, keywords, relative_pos, action, parameter=None)[source]¶ Modify existing tasks based on presence of a keyword.
Parameters: - modifier (str) – A string value which would trigger the given Modifier.
- keywords (iterable of str) – sequence of strings which are keywords for some task, which has to be modified.
- relative_pos (int) – Relative position of the task which should be modified in the presence of modifier. It’s value can never be 0. Data fields should also be considered when calculating the relative position.
- action (str) – String value representing the action which should be performed on the task. Action represents calling a arbitrary function to perform th emodification.
- parameter (object) – value required by the action.(Default None)
-
add_task
(keywords, context, rule)[source]¶ Map a function to a list of keywords
Parameters: - keywords (iterable of str) – sequence of strings which should trigger the given function
- context (Context) – A Context object created using desired function
- rule (tuple) – A tuple of integers, which act as relative indices using which data is extracted to be passed to the function passed via context.
-