The three things every lesson from here on reuses

Almost every lesson in this course is a variation on the same three lines:

parser = liteparse.LiteParse()
result = parser.parse("some/file.pdf")
text = result.text
  1. LiteParse(...): builds a parser, configured once, with whatever options you want (this course covers most of them). Called with no arguments, you get the defaults.
  2. .parse(path): runs the parse. Local, synchronous, returns a ParseResult.
  3. .text: the whole document's text, all pages concatenated in reading order, as a single string. This is almost always what you want for feeding a document into search, an LLM prompt, or a keyword check. Lesson 4 covers .pages for anything that needs to stay per-page.

A note on what you'll see printed

Run this lesson and you'll see a few [liteparse] ... timing lines before the actual output. Those come from LiteParse itself, not this lesson's code, they're on by default (quiet=False unless you set it). You'll also notice an ocr: line taking most of the time, even though product_spec.pdf is a completely normal, native-text PDF with no scanned content at all.

That's LiteParse()'s default ocr_enabled=True at work: with no argument telling it otherwise, LiteParse runs a page through OCR whenever its internal heuristics think OCR might recover more text than the native text layer alone, and one of those heuristics ("sparse-text") can trigger even on a page that already has plenty of real text, if the text happens to cover a small fraction of the page's visual area. The OCR pass ran here, but it didn't change result.text, since the native text layer already had everything. Lesson 8 covers this heuristic and the OCR contrast properly; Lesson 3 shows how to turn it off with ocr_enabled=False when you already know your documents are native-text.

Checkpoint

  • LiteParse(): builds a parser; every configuration option has a default, so this works with zero arguments.
  • .parse(path): local, synchronous, returns a ParseResult.
  • .text: the whole document's text as one string, the field you'll reach for most often.
  • ocr_enabled defaults to True: LiteParse can run OCR on a page even when native text exists, based on internal heuristics, not just when a page is obviously scanned. More on this in Lessons 3 and 8.

If anything here still feels unclear, ask before moving to Lesson 3.