Skip to main content

SectionDetectionV2Config

Struct SectionDetectionV2Config 

Source
pub struct SectionDetectionV2Config {
    pub line_height_tolerance: f32,
    pub font_size_tolerance: f32,
    pub structural_size_margin: f32,
    pub structural_size_ratio: Option<f32>,
    pub min_alpha_ratio: f32,
    pub max_depth: u32,
    pub enforce_max_depth: bool,
    pub starting_section_level: u32,
    pub inclusion_patterns: Vec<InclusionPattern>,
    pub inclusion_max_length: usize,
    pub exclusion_patterns: Vec<String>,
    pub tiebreaker_keywords: Vec<TiebreakerKeyword>,
}
Expand description

Configuration for the V2 section detection rule (V3 algorithm — Block 09).

Three-tier piecewise classifier on delta = font_size - body_size plus pre-gates (rotation, alpha-ratio) and pattern refinement (inclusion / exclusion regex) as a backup. Isolation is leaf-based, consulting the Placement.region_label set by analytics::reading_order::tag_and_resort.

Fields§

§line_height_tolerance: f32

Y-coordinate tolerance (points) for grouping bboxes onto the same visual line. Two elements within |Δy| < this in the same Region tree leaf are considered to be on the same baseline. Defaults to a value smaller than typical inter-line spacing so consecutive lines do not merge.

§font_size_tolerance: f32

Font-size tolerance (points). Defines the symmetric ±tolerance band around body size.

  • delta < -tolerance → REJECT (below-body noise).
  • |delta| ≤ tolerance → R3 (at-body band): needs bold AND isolated_in_leaf.
  • tolerance < delta ≤ structural_size_margin → R2 (medium): needs bold OR isolated_in_leaf.
  • delta > structural_size_margin → R1 (large): auto-promote unconditionally.
§structural_size_margin: f32

Size margin (points) above body text at which size alone confirms structural role. Region 1 threshold: delta > structural_size_margin → auto-promote.

§structural_size_ratio: Option<f32>

Proportional alternative to structural_size_margin. When Some, Region 1 threshold is body_size * ratio instead of body_size + margin. Default None (use margin).

§min_alpha_ratio: f32

Minimum alphabetic character ratio for a candidate to survive (inherits semantics from old rule’s min_alpha_ratio).

§max_depth: u32

Max hierarchy depth (inherits from old rule).

§enforce_max_depth: bool§starting_section_level: u32§inclusion_patterns: Vec<InclusionPattern>

Regex patterns that promote a weak/rejected candidate to a section (escape hatch — e.g., “^\d+\.\d+” for numbered subsections). Promotion additionally requires the per-pattern structural gates (require_bold, require_isolation) and a global length cap (inclusion_max_length). See CR-26 (length cap, isolation) and CR-42 (per-pattern bold/isolation gating).

§inclusion_max_length: usize

Maximum text length (in characters) for an inclusion-pattern match to promote. Real structural labels (“Article 64”, “CHAPTER II”) are short; body wrap-lines that happen to begin with a structural keyword are long. This is the synthetic gate Pass 2 needs because, unlike Pass 1, it has no bold/rarity confirming signal — pattern + isolation alone admit recital wrap-lines on documents like CELEX where font_size is degenerate.

§exclusion_patterns: Vec<String>

Regex patterns that demote a promoted candidate back to non-section (escape hatch — e.g., “^Figure\s” for figure captions).

§tiebreaker_keywords: Vec<TiebreakerKeyword>

Ordered list of (keyword_name, regex) pairs that identify the structural “tier” of a section. Consulted only when the font-size delta vs. the previous section is within font_size_tolerance (the tie). When the tie fires, keyword identity decides whether the new section is a sibling, a step-back-up to an earlier tier, or a deeper tier.

Order matters: the first matching pattern wins. Place specific keywords before generic ones (e.g. structural words before bare-numbered).

Trait Implementations§

Source§

impl Clone for SectionDetectionV2Config

Source§

fn clone(&self) -> SectionDetectionV2Config

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 SectionDetectionV2Config

Source§

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

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

impl Default for SectionDetectionV2Config

Source§

fn default() -> SectionDetectionV2Config

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SectionDetectionV2Config

Source§

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

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

impl Serialize for SectionDetectionV2Config

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.