ZhangShasha
ZhangShasha copied to clipboard
Edit Mapping
The code should provide a method to output the edit script or edit mapping. It would be a vector of the operations (insert, remove, modify) needed to transform T1 to T2.
An alternative would be to leave some comments in the code for how others could do this.
That would be a cool feature to have.
You'd have to make some alterations to the treedist
function. Basically, on each recursion, you'd note the current operation just performed and on what nodes and then store this mapping in an ever growing array.
At the end, you'd just return the array of the minimum distance mappings.
Do you want to work on this feature and I'll merge in your branch?
I tried the way you described, but soon realized it wouldn't work that way since treedist is called for many node pairs, and not just the ones that end up being the min edit script.
I did end up finding a solution that worked, though. It's a bit more involved, but I created a new method, let's call it getEditScript. getEditScript will call a slightly modified treedist() to get the distance across sub-trees while it backtracks the forestdist 2D array produced by treedist(). The solution is similar to https://github.com/DatabaseGroup/apted/blob/master/src/main/java/distance/APTED.java : computeEditMapping(). Not sure when I'll have time to clean it up for merging.
Alright, whenever you do want to push your code, I will be sure to review it and proofread it!