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: f32Y-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: f32Font-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: f32Size 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: f32Minimum alphabetic character ratio for a candidate to survive (inherits semantics from old rule’s min_alpha_ratio).
max_depth: u32Max 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: usizeMaximum 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
impl Clone for SectionDetectionV2Config
Source§fn clone(&self) -> SectionDetectionV2Config
fn clone(&self) -> SectionDetectionV2Config
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more