Parsing rules¶
Single source
This page is pulled from the Parsing rules section of the README, so the docs
and the repository never disagree. Edit the README, not this page.
qaechi-parser decides what to read, how to cut it and what counts as evidence by fixed rules, not by model judgment. Same file in, same pages and chunks out.
1. Reader: who reads the document¶
qaechi-parser picks a reader for each document from its docType, its extension and, if the
reader declares any, its sourceKind. Plugins you register take priority over the built-ins, and
the most recently registered match wins. With no source or no way to read the document the job
runs in stub mode: every value null, the reason in notes. The reader used is reported in
route.
A parser that does not recognise the layout raises LayoutError rather than guessing.
2. Load: what each format turns into¶
Every loader returns pages, and the page number travels to provenance.page.
| Format | Page = | Rules |
|---|---|---|
| PDF page | Text layer via pdfplumber (or pymupdf4llm, see Install options), ruled tables kept as markdown rows in reading order. A page with no text is kept empty and reported in notes as no text on N page(s) (likely scanned; put OCR in front). Encrypted files fail unless QAECHI_PDF_PASSWORD opens them. |
|
| PPTX | slide | Title first as # title. Shapes in reading order (top-to-bottom, then left-to-right), including shapes inside groups. Tables become \| a \| b \| rows. Charts become a series \| category... table with their values. Speaker notes follow a [notes] marker. |
| XLSX / XLSM | sheet | Every sheet, hidden sheets too (marked (hidden)). Cached values, not formulas. Blank rows dropped and trailing empty cells trimmed; empty cells in the middle stay so columns line up. 1200000.0 prints as 1200000, a midnight datetime as 2026-01-31; nothing is rounded. Up to 20,000 rows are read per sheet for parsers; the first 300 non-blank rows go to the LLM, and the sheet header says so. |
| CSV | whole file | Delimiter sniffed (, ; tab \|), UTF-8 with or without BOM. Same row rules as XLSX. |
| TXT / MD | whole file | As is. |
3. Chunk: how pages are cut¶
| Rule | Why |
|---|---|
| A sheet page is one chunk, however long. | A table split from its header loses meaning. |
Other pages are cut into table blocks (lines with 2+ \|) and prose blocks. |
A PDF page often holds both. |
| Table blocks are never split. Prose blocks over 1,000 chars are split (100-char overlap). | Retrieval gets small prose chunks without breaking tables. |
| Small neighbouring blocks are packed together up to 1,000 chars. | A table keeps the sentence that introduces it. |
Each chunk starts with [doc: <type> \| period: <p> \| p.<n>]. |
The model can cite the page. |
| Chunk text is verbatim. | Quotes are checked against it. |
4. Evidence: when a quote counts¶
Each LLM quote is searched for in the chunk text. Before matching, both sides are normalized
only for: Unicode compatibility forms (full-width 1,000, NBSP), typographic quotes and
dashes (“ ” – −), markdown the loader added (|, **, __, <br>), and runs of
whitespace. Letters, digits and their order must match exactly, so a changed digit, a moved
decimal point or a dropped minus sign is reported in quoteCheck.notInSource.
5. Grade and save¶
- Groundedness is
yes/no/unknown; without an LLM key it isunknown, neveryes. Parser results areyesbecause their values are read, not generated. - A clear
noretries once with the full context, and only ifQAECHI_REWRITEis on. - Nothing is dropped silently: skipped rows, skipped sheets, truncated sheets, empty pages and quotes not found in the source are all counted in the result.