Find Similarities between Blocks of Text between Many HTML Documents?

a 夏天 提交于 2019-12-06 06:16:47

You should consider a clone detector such as CloneDR. Good ones compare the structure of thousands of files at once regardless of the formatting, and will tell you what the files have as common elements and how those common elements vary.

CloneDR has been applied to many programming langauges. Its foundation, the DMS Software Reengeering Toolkit, already handles (dirty) HTML, so it would be pretty easy to build an HMTL CloneDR.

You don't need any complex regexps; just a simple diff analyzer will do. Just do an (Enumerable) injection, keeping only similar parts as your memo.

Here are some in Ruby:

  • ruby-diff -- Implements the text-diff algorithm from Perl
  • diff-lcs
  • HTMLdiff -- Finds the diff of two strings, and renders with pretty formatting (HTML) (Probably not exactly what you want, unless you can strip away all non-diff material from the output)

Hope this helps!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!