CourseRetrieval-Augmented Generation: The Complete Course · Module 2: Document Ingestion and Parsing · part 17 of 95
Part 17 · Module 2: Document Ingestion and Parsing

Lesson 4: Choosing a parser, then cleaning what it returns

21 min read·13 Oct 2026
Module 2 · Lesson 4 · About 50 minutes · Needs: Lessons 2 and 3 of this module (pypdf, pdfplumber, Docling), basic Python dictionaries and regular expressions

The situation

Kwame has 1,840 pages of manuals to load (a simulated count) and four parsers that all "work". He wants one answer: which parser, and how sure are we that it keeps the answers? Owen, in Finance, asks a second question: what will parsing every page cost in machine time?

Both need numbers. This lesson runs page 2 of the P9 guide through four parsers, measures what each loses and how long each takes against its answer key P9_PAGE, then cleans the output: odd characters, broken words, other languages and repeated boilerplate.

P9 page 2 PDF pypdf pdfplumber pypdfium2 docling answer key P9_PAGE + facts same key, four scores
One page, four parsers (blue: your pipeline), one answer key (green: known correct): every output is scored the same way.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.