Comparing two text paragraphs and saving in database for displaying later.

129 views
Skip to first unread message

sulakhe...@gmail.com

unread,
Mar 4, 2015, 10:06:27 AM3/4/15
to diff-mat...@googlegroups.com
Hello friends,

I am working on a Spring-MVC application in which I would like to compare two text fields and after computing the differences, mark them and save them in the database. At retrieval I can check the marks and display which text was exactly changed. As it's Spring-MVC, I am working on Java and using Javascript on frontend side.
I just started with Diff Match Patch so I don't know that much about it. What I have done till now is compare the Strings and display them. Kindly have a look at my code.

Code :

 diff_match_patch diffMatchPatch = new diff_match_patch();
 LinkedList<diff_match_patch.Diff> deltas = diffMatchPatch.diff_main(oldText,newText);
                for(diff_match_patch.Diff d : deltas){
                                System.out.println(d);
                    }
                   


I am able to see the operations like Insert, Equals, Delete, I just don't know what to do next to get which sentences got changed, mark them with some special character and persist them. Thanks a lot.
Reply all
Reply to author
Forward
0 new messages