Coverage for src / quber / core / figures / dpt3 / __init__.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-09-23 22:14 -0400

1"""The dpt-3 track: digest a v2 scan response, graft it, resolve its footnotes. 

2 

3The figure workflow's dpt-2 path reads a response as a flat chunks list. The 

4dpt-3 models return a different shape — one long text and a tree pointing into 

5it — and this package is the code that reads it. The orchestrator selects the 

6track by model name; the dpt-2 path is untouched. 

7 

8Three modules, in the order the orchestrator uses them: 

9 

10- `digest` turns one page's raw response into the track's records and projects 

11 them to the `PageScan` every downstream consumer already reads. What the 

12 projection leaves out — figure kind, structured value tables, per-value 

13 provenance — stays in the `models` records. 

14- `graft` writes the records into the document under one rule the old graft 

15 lacks: supplant content readings, preserve footnote- and caption-labelled 

16 text. 

17- `footnotes` resolves each figure's markers against two sources — the 

18 correction agent's image read and the page text the graft preserved — 

19 inserts the resolved notes after the picture, and attaches each note to the 

20 value its label matches. 

21- `blocks` groups the parse's floating text by the scan's block partition, so 

22 a stat panel's label and value travel as one unit instead of as unrelated 

23 records. 

24 

25Nomination upstream and the consumers of projected records — table capture, 

26the correction sweep, value reconciliation — are shared with the dpt-2 path, 

27unchanged. 

28""" 

29 

30from quber.core.figures.dpt3.blocks import SCAN_BLOCK, group_scanned_text 

31from quber.core.figures.dpt3.digest import ( 

32 UnrecognizedResponse, 

33 digest_page, 

34 project_scan, 

35 response_generation, 

36) 

37from quber.core.figures.dpt3.footnotes import resolve_figure_footnotes 

38from quber.core.figures.dpt3.graft import graft_figures, insert_orphan_tables, unhomed_tables 

39from quber.core.figures.dpt3.models import PageDigest 

40 

41__all__ = [ 

42 "PageDigest", 

43 "SCAN_BLOCK", 

44 "UnrecognizedResponse", 

45 "digest_page", 

46 "graft_figures", 

47 "group_scanned_text", 

48 "insert_orphan_tables", 

49 "project_scan", 

50 "resolve_figure_footnotes", 

51 "response_generation", 

52 "unhomed_tables", 

53]