def __init__(self, uterm, adornment=None, naf=False): self.marked = False self.adornment = adornment self.nsMgr = GetUterm(uterm).nsMgr newArgs = copy.deepcopy(GetUterm(uterm).arg) super(AdornedUniTerm, self).__init__(GetUterm(uterm).op, newArgs, naf=naf) self.isMagic = False
def __init__(self, network): self.skolemTerms = set() for tNode in network.terminalNodes: for rule in tNode.rules: if isinstance(rule.formula.head, Exists): network.registerReteAction( tuple([ None if isinstance(term, BNode) else term for term in GetUterm(rule.formula.head).toRDFTuple() ]), True, self)
def registerReteAction(self, headTriple, override, executeFn): """ Register the given execute function for any rule with the given head using the override argument to determine whether or not the action completely handles the firing of the rule. The signature of the execute action is as follows: def someExecuteAction(tNode, inferredTriple, token, binding): .. pass .. """ for tNode in self.terminalNodes: for rule in tNode.rules: if not isinstance(rule.formula.head, (Exists, Uniterm)): continue headTriple = GetUterm(rule.formula.head).toRDFTuple() headTriple = tuple( [None if isinstance(item, BNode) else item for item in headTriple]) tNode.executeActions[headTriple] = (override, executeFn)