Compare words not character in diff match patch using C#

255 views Asked by At

Text1 = Hello World Text2 = Hi Planet

Current output: Diff(EQUAL,"H")Diff(DELETE,"ello World")Diff(INSERT,"i Planet")

Desired Output: Diff(DELETE,"Hello World")Diff(INSERT,"Hi Planet")

The current code is giving output comparing character to character. But i want it word to word. If the word is different, it will show as not matched.

Code I have written:

        diff_match_patch dmp = new diff_match_patch();
      
        List<Diff> diff= dmp.diff_main("Hello World", "Hi Planet");

        dmp.diff_cleanupEfficiency(diff);
      
        dmp.Diff_EditCost=4;

        for (int i = 0; i < diff.Count; i++)
        {
            richTextBox1.Text += diff[i];
        }
0

There are 0 answers