Parsing Digital Documents
In this article
- Explain how a native parser reads the structure an HTML page or a digital PDF already stores, and which parts of it the application keeps.
- Turn a short HTML page into ordered, typed blocks with links, and drop the page furniture around the main content.
- Recover the reading order of a two-column PDF page from its text layer.
- Decide for a given file whether a native parser is enough or the file must go to OCR, layout or vision parsing.
- Terms defined here: text layer, reading order.
Overview
Web pages and Word files already store their headings and links, and a digital PDF stores its text. Parsing them means reading what the file stores, keeping what the application needs and dropping the rest, in the right order. Get it wrong and nothing crashes: the index just fills with sentences that join two unrelated halves, or with "Home Plans Support" on every help page.
Brightline, a home-internet provider, runs a support assistant on its website that answers customers, looks up orders and hands a conversation to a person on the support team; before the assistant can search them, its help pages, router manuals, staff handbook and past conversations are read from the systems where they are kept and turned into documents that a search index can take. The company, its pages and numbers are invented for the example.
Two files carry the lesson, the help page help-refunds (HTML) and the manual manual-bl-r7 (a 40-page digital PDF): what blocks does each file give, in which order, with which types, links and page numbers?
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- What a native parser reads
- An HTML help page: main content and furniture
- A digital PDF: two columns on one page
- Every format, one schema
- When the stored text is not enough
- Common mistakes
- Sources
- Check yourself, 13 questions