def _activate_right(self, token):
        """
        Activate from the right.

        Go over the left memory and find matching data, when found
        update the counter (substracting if the given token is invalid
        and adding otherwise). Depending on the result of this operation
        a new token is generated and passing to all children.

        """
        if token.is_valid():
            self.right_memory.append(token.to_info())
            inc = 1
        else:
            inc = -1
            self.right_memory.remove(token.to_info())

        for left in self.left_memory:
            if self.matcher(dict(left.context), token.context):
                self.left_memory[left] += inc
                newcount = self.left_memory[left]
                if (newcount == 0 and inc == -1) or \
                        (newcount == 1 and inc == 1):
                    if inc == -1:
                        newtoken = left.to_valid_token()
                    else:
                        newtoken = left.to_invalid_token()

                    for child in self.children:
                        child.callback(newtoken)
def _activate_right ( self , token ) : if token . is_valid ( ) : self . right_memory . append ( token . to_info ( ) ) inc = 1 else : inc = - 1 self . right_memory . remove ( token . to_info ( ) ) for left in self . left_memory : if self . matcher ( dict ( left . context ) , token . context ) : self . left_memory [ left ] += inc newcount = self . left_memory [ left ] if ( newcount == 0 and inc == - 1 ) or ( newcount == 1 and inc == 1 ) : if inc == - 1 : newtoken = left . to_valid_token ( ) else : newtoken = left . to_invalid_token ( ) for child in self . children : child . callback ( newtoken )
Activate from the right.

        Go over the left memory and find matching data, when found
        update the counter (substracting if the given token is invalid
        and adding otherwise). Depending on the result of this operation
        a new token is generated and passing to all children.