pyaiml21.kernel.Kernel¶
- class pyaiml21.kernel.Kernel(gm_cls: typing.Type[pyaiml21.graphmaster.graphmaster.GraphMaster] = <class 'pyaiml21.graphmaster.graphmaster.GraphMaster'>, *args, **kwargs)[source][source]¶
Backwards compatible way to work with the interpreter.
This class represents the whole interpreter, keeps the track of a bot and loading and manipulation with its files, configuration, etc.
Note that some methods are missing, or have changed type signature.
Methods
add_propertiesAdd properties to the bot.
add_substitutionsUpdate the substitutions of the bot.
brain_sizeFind the number of categories stored in the brain.
Get the corresponding bot property.
Return bot the specified bot's property.
Return a copy of session predicates.
get_predicateFind and return the value of a bot's _predicate.
get_propertyReturn the bot's property value.
get_sessionAccess arbitrary bot-user session.
init_new_userCreate a chat session for a new user, user must be a new user.
Load and learn content of the given aiml file.
learn_aimlLoad .aiml file and store its contents in the (global) graphmaster.
learn_aimlifLoad .aimlif file and store its contents in the (global) graphmaster.
learn_categoryLearn category online, during the evaluation of the response.
Attempt to load the brain global for all users from the specified file.
load_mapLearn and store AIML map m.
load_patternsLearn pattern tags.
load_setLearn and store AIML set s.
load_tagsLearn <template> tags.
preprocessNormalize the text fed to the graphmaster.
Reset bot's brain.
respondSearch graphmaster and return the reply to input_.
Store the global brain into the specified file.
search_brainSearch the bot's brain and return the appropriate template node.
Set the corresponding bot property to the value.
Set the corresponding _predicate.
vocabularyFind the number of distinct words stored as nodes in the bot's brain.
Attributes
- getBotPredicate(name: str) Optional[str][source][source]¶
Get the corresponding bot property.
- Parameters
name – name of the property
- getPredicate(name: str, sessionID: Optional[str] = None) str[source][source]¶
Return bot the specified bot’s property.
- Parameters
name – name of the property
sessionID – id of the session
- Returns
property value or empty string of not set
- getSessionData(sessionID: Optional[str]) Dict[str, str][source][source]¶
Return a copy of session predicates.
- Parameters
sessionID – id of the session
- Returns
session predicates or empty dict if session is not found
- learn(filename: str) None[source][source]¶
Load and learn content of the given aiml file.
- Parameters
filename – .aiml or .aimlif with categories to learn
- loadBrain(brain_file: str) None[source][source]¶
Attempt to load the brain global for all users from the specified file.
Does not load configuration files, nor the custom tags.
- Parameters
brain_file – filename from which to load the brain
- resetBrain() None[source][source]¶
Reset bot’s brain.
Remove the content of bot’s brain, equivalent to starting a new instance of the bot with the same name.
- saveBrain(filename: str) None[source][source]¶
Store the global brain into the specified file.
Does not save configuration files, nor the custom tags.
- Parameters
filename – filename to save the brain into