pub struct NodeTypeMergeConfig {
pub same_line: bool,
pub same_paragraph: bool,
pub ignore_region_label: bool,
pub region_overflow_threshold: Option<u32>,
pub same_depth: bool,
pub max_y_gap: Option<f32>,
pub prose_line_separator: String,
pub table_line_separator: String,
}Expand description
Merge configuration for one element type. Algorithm: partition coarsely at
(page, element_type), walk reading-order-sorted bucket, split into a new
merge group whenever any constraint fails between consecutive elements.
Fields§
§same_line: boolRequire both elements be in the same Tika line (line_number equality).
same_paragraph: boolRequire both elements be in the same Tika paragraph (paragraph_number equality).
true is the conservative prose-safe default for body prose; false for
Section (a multi-paragraph bold title in one leaf is still one Section).
ignore_region_label: boolDrop region_label from the equivalence key for this element type.
true collapses all elements of this type within a page into one bucket
regardless of which Region tree leaf they sit in. Default false keeps
region as a partition dimension; flipped on by Header / Footer defaults
(per-page running header / footer is one logical unit).
region_overflow_threshold: Option<u32>Stopgap for Tika’s row-keyed paragraph_number in 2-column body layout
(see CR-38).
When Some(n), a pre-scan counts distinct paragraph_numbers per
(page, element_type, region_label). If the count is >= n for a
region, paragraph_number is dropped from the key for that region —
the whole region collapses into one bucket. Catches the gpt2-style
failure mode where Tika emits one <p> per visual row across both
columns, leaving each column-region with one paragraph_number per
line.
Tradeoff: when the threshold fires, real within-column paragraph breaks are lost. CR-38 replaces this heuristic with bbox-derived paragraph detection (modal body X + indent rule + Y-gap distribution), which preserves paragraph structure in 2-column layouts. This knob is the Block 10 ship-it pragma; CR-38 is the structurally-correct fix.
None disables the fallback (clustering uses paragraph_number
directly).
same_depth: boolRequire both elements have equal hierarchy_level. Prevents a section
header and a sub-section header on the same page from merging just
because they share a band-collapsed bucket.
max_y_gap: Option<f32>Maximum Y-gap (in points) between last.bbox.bottom and current.bbox.top.
None disables the proximity check. Geometric distance separates “one
logical title fragmented across bands” (small gap) from “two unrelated
nodes on the same page” (large gap).
prose_line_separator: StringSeparator between merged elements crossing line boundaries when the element’s band has ≤2 columns (prose flows continuously).
table_line_separator: StringSeparator between merged elements crossing line boundaries when the element’s band has >2 columns (table-like — preserve rows).
Implementations§
Source§impl NodeTypeMergeConfig
impl NodeTypeMergeConfig
Sourcepub fn default_section() -> NodeTypeMergeConfig
pub fn default_section() -> NodeTypeMergeConfig
Section default: within-region merge with depth equality + proximity. A multi-line bold chapter title in one Region tree leaf at one depth is one Section regardless of how Tika sliced paragraphs across the bands.
Sourcepub fn default_paragraph() -> NodeTypeMergeConfig
pub fn default_paragraph() -> NodeTypeMergeConfig
Paragraph (and List / ListItem) default: within-region, with Tika paragraph_number as the within-region granularity refinement. This solves the small-margin “whole page = one leaf” failure mode where region alone is too coarse — paragraph_number gives the within-leaf Y-gap clustering Tika has already computed.
region_overflow_threshold: Some(10) catches Tika’s row-keyed
paragraph_number in 2-column body layouts (see CR-38). When a
(page, region_label) produces ≥10 distinct paragraph_numbers,
paragraph_number is dropped and the region collapses to one bucket.
Header / Footer default: collapse all per-page H-N / F-N labels into
one bucket per (page, type). Per-page running headers and footers are
one logical unit — different H-N indices are just multiple fragments
of the same chrome row.
Sourcepub fn default_margin() -> NodeTypeMergeConfig
pub fn default_margin() -> NodeTypeMergeConfig
Margin default: keep region_label as a partition dimension. A sidebar
block and a page-edge marginal note are different logical units even
though they’re both Margin; merging within one Margin region is fine,
merging across is not.
Trait Implementations§
Source§impl Clone for NodeTypeMergeConfig
impl Clone for NodeTypeMergeConfig
Source§fn clone(&self) -> NodeTypeMergeConfig
fn clone(&self) -> NodeTypeMergeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more