Skip to main content

Module spatial_table_detector

Module spatial_table_detector 

Source
Expand description

Spatial table detection from PDF text layout.

Implements table detection according to ISO 32000-1:2008 Section 5.2 (Coordinate Systems). Uses X and Y coordinate clustering to identify table structure in PDFs that lack explicit table markup in the structure tree.

Structs§

DetectedTable
Backward compatibility: Indices of spans belonging to a table.
SpatialTableDetector
Backward compatibility: Table detector wrapper.
TableDetectionConfig
Configuration for spatial table detection.

Enums§

TableStrategy
Strategy for detecting table boundaries (v0.3.14).

Functions§

consolidate_adjacent_table_fragments
Consolidate vertically-adjacent tables that share an identical column structure into a single multi-row table.
consolidate_adjacent_table_fragments_with_tol
Like consolidate_adjacent_table_fragments but with a caller-chosen vertical merge tolerance. The default 3.0 pt tolerance assumes fragments abut (a ruling line between every row leaves ~0 gap). The H-rule-bounded detector, however, emits one fragment per rule-delimited band, so two bands of the SAME logical table are separated by a full inter-row pitch (rule stroke + leading) — often ~10-15 pt. A larger y_tol lets those bands rejoin. Safety rests on the unchanged column gating in can_merge_tables (equal col_count + X-start ≤ x_tol + width ≤ x_tol): two genuinely distinct tables sharing all three within one row-height are vanishingly rare, whereas bands of one ruled table match them exactly.
detect_tables_from_spans
Detect tables from spatial layout of text spans.
detect_tables_from_spans_column_aware
Column-aware text-only table detection.
detect_tables_with_lines
Detect tables using vector lines and text spans (main entry point for hybrid detection).