Extracting Structured Data from Text and Documents
This lesson explains how information extraction turns documents such as invoices, contracts, forms and reports into structured data that systems can store, search and act on.
Learning outcomes
After completing this lesson, you will be able to:
- Explain the role of OCR and layout analysis.
- Explain how field extraction with a schema returns named, typed values.
- Describe how information is extracted from text that is already digital.
From pixels to text: OCR
Scanned documents and photos are images, so the first step is optical character recognition (OCR), which detects lines and words and converts them into text, with their positions on the page. OCR handles printed and handwritten text in many languages. By itself, OCR only produces text: it does not know that 1,240.00 is the invoice total.
Layout analysis
Layout analysis recognizes the structure of a page: paragraphs, headings, tables with rows and columns, selection marks such as ticked boxes, and figures. Preserving structure matters because meaning often depends on it; a value in a table only makes sense with its row and column headers. Representing the result as Markdown keeps headings and tables in a form that both people and language models can read.
Field extraction with a schema
Field extraction returns specific values as named, typed fields: VendorName (string), InvoiceDate (date), Total (number), Items (an array of objects with description, quantity and price). A schema lists the fields to return and describes each one. Modern extraction is semantic: it understands meaning, so it finds the invoice number whether the label says Invoice No., Inv # or nothing at all.
Fields can be extracted (the value appears in the document), classified (the document or value is assigned one of a set of categories, such as document type) or generated (a value is inferred, such as a one-sentence summary). Each value comes with a confidence score and its location in the source, so that uncertain values can be checked by a person.
The following table recaps how the three techniques build on each other.
| Technique | Output | Example |
|---|---|---|
| OCR | Text and its positions | All words on a scanned invoice |
| Layout analysis | Structure: paragraphs, headings, tables, selection marks | The line-item table with its columns |
| Field extraction | Named, typed values with confidence | Total = 1,240.00 (confidence 0.97) |
The following diagram shows how the techniques build on each other and the three field methods.

OCR, layout or fields?
Extraction from plain text
Text that is already digital, such as emails and chat messages, skips OCR. Entity detection finds standard entities, and generative models or schema-based analyzers extract custom fields, such as the order number and requested action from a customer email.
From text to fields
OCR or field extraction
An accounts team receives supplier invoices in many layouts. It needs the supplier name, invoice date and total entered into its finance system automatically, and wants uncertain values reviewed. A developer proposes running OCR and searching the text for the word Total.
OCR plus keyword search breaks when a supplier labels the total Amount due or places it in a table. Schema-based field extraction finds the values by meaning across layouts and returns confidence scores, so values below a threshold can go to a review queue.
Why do extracted fields come with confidence scores?
Show answer
So that uncertain values can be sent to a person for review instead of being used automatically.
Exam Tips
Remember for the exam
- OCR produces text; layout analysis adds structure; field extraction returns typed values.
- Schemas define the fields; semantic extraction works even when labels differ.
- Confidence scores let uncertain values be reviewed by a person.