[pmwiki-users] compare revisions down to single letters

Joachim Durchholz jo at durchholz.org
Thu Jun 9 16:38:15 CDT 2005


Patrick R. Michaud wrote:

> On Thu, Jun 09, 2005 at 10:27:30PM +0200, Stephan Schildberg wrote:
> 
>> do you know a way how to compare two revisions by the resolution
>> down to single letters?
> 
> I haven't found a good algorithm for doing this -- if one can point
> me to one then I'll be glad to see about incorporating it into
> PmWiki.

If anybody is interested: the diff algorithm was ported to Perl (which 
is less interesting) and got quite clearly documented.

Module page:
http://cpan.uwinnipeg.ca/dist/Algorithm-Diff

General introduction into what it all is:
http://cpan.uwinnipeg.ca/htdocs/Algorithm-Diff/README.html
This also has a link to the article describing the basic algorithm.
However, studying the Perl packaging might still be worthwhile, because 
it can work on arbitrary lists of things, not just on lines, words, or 
characters. This can be used to sensibly diff structured data; i.e. you 
have a sequence of "sections" that you compare, and if you find a 
difference, you can do a (say) word-based diff of the section contents.
The Perl package also contains some optimisations, so it might be 
interesting to compare the original algorithm and the implementation.

Usage information (interesting to identify the interesting functions in 
the Perl sources):
http://cpan.uwinnipeg.ca/htdocs/Algorithm-Diff/Algorithm/Diff.html

The sources:
http://cpan.uwinnipeg.ca/cpan/authors/id/T/TY/TYEMQ/Algorithm-Diff-1.1901.zip
Usually I abhor Perl, but this one was actually readable. It isn't 
exactly heavily commented though, so reasonable fluency in Perl is required.


I'd actually *love* to do that. Getting it to work and through a couple 
of bug-fixing and optimisation rounds would take me roughly a full 
month, and unfortunately that's more than I can afford to invest 
(barring the unlikely case that somebody is willing to pay me).

So: if anybody is interested in porting this to PHP, just go ahead :-)

Regards,
Jo



More information about the pmwiki-users mailing list