Showing posts with label algorithmics. Show all posts
Showing posts with label algorithmics. Show all posts

Thursday, July 30, 2009

Text compare

This is not flex related, I know but since I don't have another blog to post this in, I will put it in this one:) so bare with me. Following my last post which was about implementing track changes in flex side, I decided to get a text comparison algorithm on the server java side to compare two texts and return a merged version with all additions and deletions.

I found a number of character/line comparison algos but the output wasn't that nice and i decided to look for a word by word comparison for change tracking. What I found was a "longest common subsequences algorithm" for Java but it was based on two linked lists or arrays. So decided to complement this with a textutil compare method that receives as a parameters two version of the text and produces a merged copy with deletions wrapped in "[-" & "-]" and additions wrapped in "[+" & "+]".