Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Difference in result of cleanupSemantic() function on iOS and Android. #121

Description

@pradiptilala

We have used objective-C code for iOS and Java code for Android from library. We are using same set of function to find the difference of string in Android and iOS.

But for some texts we are getting difference results for cleanupSemantic() function on Android and iOS.

  1. In code first we have used the diff_main() function which returns us list of Diff models. In iOS and Android its returning list of Diff() with length 399.

  2. Second, we have used cleanupSemantic() to get the result list of Diff() models. In iOS, cleanupSemantic() function returns list of Diff() with length 8 whereas in Android same function returns list of Diff() with length 11.

  3. Then we are using the diff_prettyHtml function to get highlighted text. We are using this highlighted html text to load into the WebView.

  4. We have customized diff_prettyHtml function to show inserted text in only green background without underline.

Due to difference in result of cleanupSemantic() function on iOS and Android. We are not able to show same text difference on both iOS and Android devices.
iOS result image:
iOS_text

Android result image:
android_text-min
From above images you can find that last 2 lines in Android is different from that is in iOS.
You can also use previousText and updatedText value that we have posted in below example to replicate the issue.

Code used on Android side is as follows:

String **previousText** = “Customer shall pay Consultant’s expenses $200000 per month, as determined by Consultant in its reasonable business judgment, for performing the Services under this Agreement. Consultant shall invoice Customer for Services. All such invoiced amounts become due and payable to Consultant upon Client’s receipt of such invoice. Amounts that are not paid within fifteen (15) days following Customer’s receipt of such invoice will incur a penalty of $10000 per month or the maximum allowed by law, whichever is less.  Customer shall pay any amounts incurred by Consultant in the collection of past-due amounts owed, including, but not limited to, reasonable attorneys’ fees and costs. This is updated now<br>”;

String **updatedText** = “!%@%%!%%@%%@515252555115   A computer program can easily produce gibberish - especially if it has been provided with garbage beforehand. This program does something a little different. It takes a block of text as input and works out the proportion of characters within the text according to a chosen order. For example, an order of 2 means the program looks at pairs of letters, an order of 3 means triplets of letters and so on. The software can reg”;

diff_match_patch diffMatchPatch = new diff_match_patch();
                   
LinkedList<diff_match_patch.Diff> listStrings = diffMatchPatch.diff_main(previousText, updatedText);

diffMatchPatch.diff_cleanupSemantic(listStrings);

String sb = diffMatchPatch.diff_prettyHtmlCustom (listStrings);

webViewInstance.loadDataWithBaseURL("", sb, "text/html", "utf-8", "");

We have some of the questions regarding the same:

  1. Is this difference in results is due to different implementation of library in Objective-C and Java ?
  2. Is there is any suggested modification or solution for this issue to make it work for both iOS and Android ?

Please suggest us an solution to overcome this issue as soon as possible.

We are very near to our app release, prompt reply will be very helpful.

Thanks,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions