Exemplo n.º 1
0
 def removeItem(self, item):
     try:
         self.items.remove(item)
     except KeyError:
         raise ValueError(item.flatten(), [x.flatten() for x in self.items])
     if not self.items:
         self.empty = True
         for c in self.children:
             if isinstance(c, JoinNode):
                 dequeRemove(c.alphaNode.successors, c)
Exemplo n.º 2
0
 def rightActivate(self, triple_holder):
     if self.alphaNode.empty:
         self.relinkBeta()
         if self.parent.empty:
             dequeRemove(self.alphaNode.successors, self)
     triple = triple_holder.triple
     env = triple_holder.env
     for token in self.parent.items:
         newBinding = self.test(token, env)
         if newBinding is not None:
             ##                if token in self.falseMatches:
             ##                    falseTriple = self.falseMatches[token]
             ##                    del self.falseMatches[token]
             ##                    if False and self.retractTriple is not None:
             ##                        self.retractTriple(falseTriple)
             for c in self.children:
                 c.leftActivate(token, triple, newBinding)
Exemplo n.º 3
0
    def rightActivate(self, triple_holder):
        if self.reachedGoal():
            # We reached a goal, so this rule should be turned off.
#            print "ALREADY REACHED A GOAL!"
            return

        if self.alphaNode.empty:
            self.relinkBeta()
            if self.parent.empty:
                dequeRemove(self.alphaNode.successors, self)
        triple = triple_holder.triple
        env = triple_holder.env
        for token in self.parent.items:
            newBinding = self.test(token, env)
            if newBinding is not None:
##                if token in self.falseMatches:
##                    falseTriple = self.falseMatches[token]
##                    del self.falseMatches[token]
##                    if False and self.retractTriple is not None:
##                        self.retractTriple(falseTriple)
                for c in self.children:
                    c.leftActivate(token, triple, newBinding)