Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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)