Answers.Body: <p>Define what is: <em>"fix it at the first place"</em>.</p>
  
  <p>If you want to fix wrong output from OCR analysis, a simple solution on an infinite set of TOCs you will never make.
  You will never apply all variations. You would have to create a machine learning algorithm that would analyze each TOC variant.</p>
  
  <p>Or count substrings of the same characteristics (in simple TOC).</p>
  
  <pre><code>Chapter number
  Chapter number
  Chapter number
  Chapter number
  Chapter number
  ...
  </code></pre>
  
  <p>= 5</p>
  
  <pre><code>Chapter title
  Chapter title
  Chapter title
  Chapter title
  Chapter title
  ...
  </code></pre>
  
  <p>= 5</p>
  
  <p>If you want to fix OCR analysis, it's a good to answer:
  <em>What OCR tool do you use?</em></p>
  
  <p>For example, in <a href="https://en.wikipedia.org/wiki/Tesseract_(software)" rel="nofollow noreferrer">Tesseract</a> you can set, that text is processed by rows instead of columns.</p>
  
  <p><a href="https://i.sstatic.net/eQNMF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/eQNMF.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-10T05:21:08.787Z
Answers.Text: This sounds promising. What GUI do you use to make that screenshot? I've checked the [3rd party projects](https://github.com/tesseract-ocr/tesseract/wiki/User-Projects-%E2%80%93-3rdParty) but don't know which one
Answers.UserDisplayName: Ooker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-10T06:00:28.873Z
Answers.Text: I've opened a question in Software Recommendation: [What OCR tools can recognize text by rows instead of columns?](https://softwarerecs.stackexchange.com/q/51049/6389)
Answers.UserDisplayName: Ooker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-10T18:12:20.190Z
Answers.Text: @Ooker : I think most of the set of OCR tools have the ability to set how the page should be analyzed.
  The picture is my schematic illustration. But this borders also shows FineReader and the advanced GUI for Tesseract [gImageReader](https://www.downloadcrew.com/article/33508-gimagereader) ([GitHub](https://github.com/manisandro/gImageReader)).
  But in automatic analysis you do not need a GUI if you do not want to manually edit something IMHO. Because you can not use automatic batch processing over a large amount of TOC if you want to check and edit each TOC.
Answers.UserDisplayName: Stilgar Dragonclaw
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-02T04:12:44.767Z
Answers.Text: @Ooker your question on OCR tools recommendation is removed. Did you move it to somewhere else?
Answers.UserDisplayName: raf
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-02T14:35:30.487Z
Answers.Text: @raf it was deleted by the roomba for being inactive. [I reask it](https://softwarerecs.stackexchange.com/q/90925/6389). Hope it lives longer
Answers.UserDisplayName: Ooker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-10T00:38:07.717Z
Answers.LastActivityDate: 2018-07-10T00:57:27.487Z
Answers.LastEditDate: 2018-07-10T00:57:27.487Z
Answers.UserDisplayName: Stilgar Dragonclaw
Answers.Body: <p>Not really answer the question, but some books in Google Books have TOC:</p>
  
  <p><img src="https://i.sstatic.net/8pZRa.png" alt=""></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-21T13:57:17.487Z
Answers.LastActivityDate: 2018-07-10T06:00:56.807Z
Answers.LastEditDate: 2018-07-10T06:00:56.807Z
Answers.UserDisplayName: Ooker
Body: <p>Usually when OCR an table of content the columns are separated by a large space, so the outputs are not properly order. For example, for an table like this:</p>
  
  <p><img src="https://i.sstatic.net/hAlQt.png" alt=""></p>
  
  <p>The output would be:</p>
  
  <pre><code>The Rank Function
  Permutations of Atoms
  Pure Set Theory and Axiom System ZF
  3.5
  3.6
  3.7
  </code></pre>
  
  <p>I'd like it to be:</p>
  
  <pre><code>3.5 The Rank Function\112
  3.6 Permutations of Atoms\116
  3.7 Pure Set Theory and Axiom System ZF\118
  </code></pre>
  
  <p>But different TOCs has different the output patterns, so there is no way to build a regex script to automatically fix every book. The best approach is to fix it at the first place. But how?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-31T02:33:07.193Z
Comments.Text: Which OCR tool do you prefer using?
Comments.UserDisplayName: raf
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-08-01T17:49:11.070Z
Comments.Text: I haven't explored that tool much so I have no idea
Comments.UserDisplayName: Ooker
Tags: <table-of-contents><ocr><programming><optimization>
Title: How to OCR tables of contents to proper outputs?
UserDisplayName: Ooker
ThreadText: # How to OCR tables of contents to proper outputs?
  
  (Asked by: username_0 on 2018-05-20)
  
  Usually when OCR an table of content the columns are separated by a large space, so the outputs are not properly order. For example, for an table like this:
  
  The output would be:
  The Rank Function
  Permutations of Atoms
  Pure Set Theory and Axiom System ZF
  3.5
  3.6
  3.7
  
  I'd like it to be:
  3.5 The Rank Function\112
  3.6 Permutations of Atoms\116
  3.7 Pure Set Theory and Axiom System ZF\118
  
  But different TOCs has different the output patterns, so there is no way to build a regex script to automatically fix every book. The best approach is to fix it at the first place. But how?
  
  **Tags:** table-of-contents, ocr, programming, optimization
  
  > **Comments:**
  > **username_1**: Which OCR tool do you prefer using?  
  > **username_0**: I haven't explored that tool much so I have no idea  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-07-10. Score: 2 | Accepted answer
  
  Define what is: "fix it at the first place".
  If you want to fix wrong output from OCR analysis, a simple solution on an infinite set of TOCs you will never make.
  You will never apply all variations. You would have to create a machine learning algorithm that would analyze each TOC variant.
  Or count substrings of the same characteristics (in simple TOC).
  Chapter number
  Chapter number
  Chapter number
  Chapter number
  Chapter number
  ...
  
  = 5
  Chapter title
  Chapter title
  Chapter title
  Chapter title
  Chapter title
  ...
  
  = 5
  If you want to fix OCR analysis, it's a good to answer:
  What OCR tool do you use?
  For example, in Tesseract you can set, that text is processed by rows instead of columns.
  
  > **Comments:**
  > **username_0**: This sounds promising. What GUI do you use to make that screenshot? I've checked the [3rd party projects](https://github.com/tesseract-ocr/tesseract/wiki/User-Projects-%E2%80%93-3rdParty) but don't know which one  
  > **username_0**: I've opened a question in Software Recommendation: [What OCR tools can recognize text by rows instead of columns?](https://softwarerecs.stackexchange.com/q/51049/6389)  
  > **username_2**: @username_0 : I think most of the set of OCR tools have the ability to set how the page should be analyzed. The picture is my schematic illustration. But this borders also shows FineReader and the advanced GUI for Tesseract [gImageReader](https://www.downloadcrew.com/article/33508-gimagereader) ([GitHub](https://github.com/manisandro/gImageReader)). But in automatic analysis you do not need a GUI if you do not want to manually edit something IMHO. Because you can not use automatic batch processing over a large amount of TOC if you want to check and edit each TOC.  
  > **username_1**: @username_0 your question on OCR tools recommendation is removed. Did you move it to somewhere else?  
  > **username_0**: @username_1 it was deleted by the roomba for being inactive. [I reask it](https://softwarerecs.stackexchange.com/q/90925/6389). Hope it lives longer  
  
  ---
  
  ### Answer by username_0 on 2018-05-21. Score: -1
  
  Not really answer the question, but some books in Google Books have TOC:
  
  ![](https://i.sstatic.net/8pZRa.png)
  
  
  ---
  
  