3

I want to compare two editions of one book. The book is very long and the editions are close but not identical.

I have extracted the texts with OCR. The obtained text-files have mistakes and many things left from text formating. Now I want to make a rough comparison of the text-files --- I want to ignore most of the things, but I need to capture something like a sentence or at least new paragraph.

The file comparison (like meld) does not seem to be useful for this (ignoring white space does not help at all).

Any suggestion?

3
  • Can you program?
    – Mawg
    Commented Jun 30, 2017 at 8:33
  • 1
    @Mawg I can write a script, but not good at that. Commented Jun 30, 2017 at 15:09
  • Actually, the coding would not be the hard part - that would be figuring out the algorithm
    – Mawg
    Commented Jul 1, 2017 at 8:37

2 Answers 2

4

I think a good buzzword here would be "fuzzy diff".

Possible answer: https://github.com/google/diff-match-patch

online tool to evaluate: https://neil.fraser.name/software/diff_match_patch/demos/diff.html (activate efficiency cleanup)

Technical explanations of the algorithm: https://neil.fraser.name/writing/diff/

Other possibilities and related questions:

https://stackoverflow.com/questions/3108274/generate-fuzzy-difference-of-two-files-in-python-with-approximate-comparison

https://pypi.python.org/pypi/fuzzywuzzy

Looking at the motivation for the question it might also be possible to take some software which can compare two pdfs visually (or based on available ocr layer) such as https://github.com/zeliboba/DiffPDF-app newer versions are commercial: http://www.qtrac.eu/diffpdf.html

alternatives (really different in spite of similar names): https://github.com/JoshData/pdf-diff http://vslavik.github.io/diff-pdf/

I have personally only tried the DiffPDF-app and at least in my case it did not seem work 100% perfectly in my case.

0

I would use KDiff3 for such purpose.

Some benefits for your need:

  1. Thanks to the summary of differences in the vertical columns, you can easily see where the differences are.
  2. You can see within the same line of text if there are differences.
  3. You can easily reload one or the other file (by clicking in its path field and hitting "Enter") if it was edited with another editor and the comparison will refresh automatically.

Some screenshots here.

I like using Kdiff3 to compare, edit with PSPad, and refresh in Kdiff3.

3
  • It is not good for texts extracted with OCR. Small differences have to be ignored. Commented Aug 20, 2019 at 14:45
  • Are there two many small differences? If not, why simply editing one of the files to purge all small differrences and refresh the comparison?
    – OuzoPower
    Commented Aug 23, 2019 at 9:39
  • Is there an automatic way to this? Commented Aug 23, 2019 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.