ext ¶
grounded ¶
Function decorator which registers a purely Python grounded function using its name as a token and unwrap=True. There are two ways of using this decorator: - @grounded without arguments and parentheses in extensions - @grounded(metta), where metta is a MeTTa instance, within Python scripts Note that MeTTa object is passed to the decorator - not to the grounded function, and @grounded creates an atom out of the function itself (which differs from register_atoms, which decorates a function returning mappings from tokens to atoms)
Source code in python/hyperon/ext.py
mark_register_function ¶
Mark function as function which registers MeTTa atoms or tokens. The following attributes are added to the decorated function: - metta_type - value of the 'type' parameter - metta_pass_metta - value of pass_metta parameter
Parameters¶
type: Kind of the register function: RegisterType.TOKEN if function register tokens; RegisterType.ATOM if it register atoms. args: args passed to decorator. If no argument are used in decorator then this list contains only function to be decorated. If decorator has some arguments then this list doesn't contain function and keeps decorator arguments instead. kwargs: kwargs passed to decorator. If arguments are used in decorator then it contains named arguments otherwise it is empty.
Source code in python/hyperon/ext.py
register_atoms ¶
Function decorator which registers returned pairs of regular expressions and atoms in a Tokenizer using the RunContext.register_atom() method.
Parameters¶
pass_metta: Pass instance of MeTTa class to the decorated function as an argument. Default is False.
Source code in python/hyperon/ext.py
register_tokens ¶
Function decorator which registers returned pairs of regular expressions and lambdas in a Tokenizer using the RunContext.register_token() method.
Parameters¶
pass_metta : bool, optional Pass instance of MeTTa class to the decorated function as an argument. Default is False.