Skip to main content

NodeTypeMergeConfig

Struct NodeTypeMergeConfig 

Source
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: bool

Require both elements be in the same Tika line (line_number equality).

§same_paragraph: bool

Require 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: bool

Drop 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: bool

Require 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: String

Separator between merged elements crossing line boundaries when the element’s band has ≤2 columns (prose flows continuously).

§table_line_separator: String

Separator between merged elements crossing line boundaries when the element’s band has >2 columns (table-like — preserve rows).

Implementations§

Source§

impl NodeTypeMergeConfig

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> NodeTypeMergeConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeTypeMergeConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for NodeTypeMergeConfig

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<NodeTypeMergeConfig, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for NodeTypeMergeConfig

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.