GNaive / naive-rete

Python RETE algorithm
MIT License
64 stars 35 forks source link

Function "delete_descendents_of_token" missing #26

Open Cybernetic1 opened 5 years ago

Cybernetic1 commented 5 years ago

In file ncc_node.py, line 65:

Token.delete_token_and_descendents(token)

should actually be Token.delete_descendents_of_token(token).

This function is explained in [Doorenbos 1995] section 2.8 (p.49). The pseudo-code is in p.158 of Appendix A.

Just add this function in Python, under class Token, in common.py:

@classmethod
def delete_descendents_of_token(cls, t):
    """
    :type t: Token
    """
    while t.children != []:
        cls.delete_token_and_descendents(t.children[0])

When the bug is not fixed, we get some errors when an NCC Partner node tries to delete tokens and complains that the tokens are not in the list.

Cybernetic1 commented 5 years ago

PS: the right_activation function in negative_node.py needs to be changed in the same manner as well (line 50).

dbbbit commented 4 years ago

could you give a test case, i can't remember the detail now :(