python 编辑距离_如何计算树编辑距离是多少?
I need to calculate the edit distance between trees for a personal project of mine.This paper describes an algorithm, but I can't make heads or tails out of it.Are you aware of any resources that ...

I need to calculate the edit distance between trees for a personal project of mine. This paper describes an algorithm, but I can't make heads or tails out of it. Are you aware of any resources that describe an applicable algorithm in a more approachable way? Pseudocode or code would be helpful, too.
解决方案
Here's some java source code (gzipped tarball at the bottom) for a Tree Edit Distance algorithm that might be useful to you.
The page includes references and some slides that go through the "Zhang and Shasha" algorithm step-by-step and other useful links to get you up to speed.
Edit: While this answer was accepted because it pointed to the Zhang-Shasha algorithm, the code in the link has bugs. Steve Johnson and tim.tadh have provided working Python code. See Steve Johnson's comment for more details.
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐




所有评论(0)