Live data from Hacker News

Ask HN: What is the best method for turning a scanned book as a PDF into text?

news.ycombinator.com

41–50 of 122 posts

Re: Ask HN: What is the best method for turning a scanned book as a PDF into text?

#41
We are working on a project to have original language on the left and translation on the facing page. Instead of perfect translations or OCR, we try to report error rates with random sampling. We plan to have the texts editable on a Wikimedia server. Curious if you know similar efforts!

Re: Ask HN: What is the best method for turning a scanned book as a PDF into text?

#42
I have not seen this answer so I’ll chime in:

There is a lot of enthusiasm around language models for OCR and I have found that generally they work well, however I have had much better results, especially if there are tables etc., by sending the raw page to the llm along with the ocrd page, and asking it transcribe from the image and validate words/character sequences against the ocr.

This largely solves for numbers and things being jumbled or hallucinated.

I recently tested llamaparse after trying it a year prior and was very impressed. You may be able to do your project on the free tier, and it will do a lot of this for you.

Re: Ask HN: What is the best method for turning a scanned book as a PDF into text?

#44

Copyright issues aside (e.g. if your thing is public domain), the galaxy-brain approach is to upload your raw scanned PDF to the Internet Archive (archive.org), fill in the appropriate metadata, wait about 24 hours for their post-upload format-conversion tasks to run automatically, and then download the size-optimized and OCR-ized PDF from them. I've done this with a few documents from the French and Spanish national…

Last time I checked a few months ago, LLMs were more accurate than the OCR that the archive is using. The web archive version is/was not using context to figure out that for example “in the garden was a trge” should be “in the garden was a tree”. LLMs depending on the prompt do this.

Re: Ask HN: What is the best method for turning a scanned book as a PDF into text?

#47
Seeing blind recommendations for AI slop is very disappointing for HN.

For OP, there is a library written in rust that can do exactly what you need with very high accuracy and performant [1].

Would need to OCR dependencies to get it to work on scanned books [2].

[1] https://github.com/yobix-ai/extractous

[2] https://github.com/yobix-ai/extractous?tab=readme-ov-file#-s...

Re: Ask HN: What is the best method for turning a scanned book as a PDF into text?

#48

I did this very recently for a 19th century book in German with occasionally some Greek. The method that produces the highest level of accuracy I've found is to use ImageMagick to extract each page as a image, then send each image file to Claude Sonnet (encoded as base64) with a simple user prompt like "Transcribe the complete text from this image verbatim with no additional commentary or explanations". The whole thi…

Is it really necessary to split it into pages? Not so bad if you automate it I suppose, but aren't there models that will accept a large PDF directly (I know Sonnet has a 32MB limit)?

They all accept large PDFs (or any kind of input) but the quality of the output will suffer for various reasons.

Re: Ask HN: What is the best method for turning a scanned book as a PDF into text?

#49
post #47

Seeing blind recommendations for AI slop is very disappointing for HN. For OP, there is a library written in rust that can do exactly what you need with very high accuracy and performant [1]. Would need to OCR dependencies to get it to work on scanned books [2]. [1] https://github.com/yobix-ai/extractous [2] https://github.com/yobix-ai/extractous?tab=readme-ov-file#-s...

That looks rather nice, actually. Thanks.

I especially like the approach to graalify Tika.

Re: Ask HN: What is the best method for turning a scanned book as a PDF into text?

#50
I've found there's a big difference in OCR accuracy where it comes to handwriting. For printed text, I've used tesseract, but it seems to miss a lot for handwriting. In my experience, google cloud vision is far more accurate at transcribing handwriting. Haven't tried other cloud based tools, so I couldn't tell you if it's better, but I would say that overall, the cloud based ones seem to be much better at handwriting or oddly formed text, but that for basic typeset printed text, open source apps like tesseract do well.
Post reply on HN