Open BramVanroy opened 4 years ago
There was an error in my initial code of the APTED example. Now they do behave the same. The only difference seems to be that zss doesn't return all operations, unless I am missing something.
The operations code was a external feature contribution (and I have to admit I haven't used it). There could very well be a bug in it -- and it certainly looks like B and D should have been removed. Since the distance being returned is correct my guess is the operations mapping is not correct.
The operations code was a external feature contribution (and I have to admit I haven't used it). There could very well be a bug in it -- and it certainly looks like B and D should have been removed. Since the distance being returned is correct my guess is the operations mapping is not correct.
I think so, too. Unfortunately I don't have the time to look further into this. As per your suggestion over email, I will use APTED in the future.
I ran into this problem earlier. Even simple trees seem to fail, for example
from zss import Node, simple_distance
bar = Node("f")
foo = Node("f")\
.addkid(Node("a"))\
.addkid(Node("b"))\
.addkid(Node("c"))\
.addkid(Node("d"))
print(simple_distance(bar, foo, return_operations=True))
# (4.0, [<Operation Insert>, <Operation Match>])
Not really sure what the problem is or how to fix it, but comparing to implementations in other languages, there's a step that this library doesn't perform here:
https://github.com/kaby76/ZhangShashaCSharp/blob/main/Tree.cs#L295-L296
but fd
and partial_ops
can't be indexed with i
and j
so can't be done here.
I'm not sure whether this is expected behaviour or not. I have two trees. One tree is basically the subtree of another where some nodes are dropped (B, C, E) and where one node has shifted a level(L).
Printed output:
When looking at the operations, though, I don't see any operations done on the labels 'B' and 'C'. Is that specific to the algorithm or the implementation?
As a comparison, here is the output of the same tree comparison with APTED:
Output of apted:
Thanks in advance!