timtadh/zhang-shasha

custom nodes

Daniel63656 opened this issue · 1 comments

Using custom trees requires a custom Node class with get_children() and get_label() method. This means, that a custom tree must be transformed completely into custom classes first. It would be much simpler, if zss.simple_distance would take functions that map from node to children like this for example:

def get_children(node):
    if isinstance(node, Tree):
        return node.children
    # else leaf
    return []

Simply by making node an input argument of these functions, the library can be used with custom trees without transforming into custom classes

I saw you already do that, my bad. Maybe add this to the usage in README