Implement Phase 4.4 block formation with 5 ordered heuristics for grouping lines into semantic blocks (paragraphs, headings, etc.): 1. Vertical gap > 1.5 * line_height → new block 2. Indent change > 0.03 * column_width → new block 3. Font size change > 1pt → new block 4. Rendering mode change → new block 5. Column boundary → MANDATORY block break Changes: - Extended Line<S> with median_font_size, rendering_mode, column fields - Added LineMetadata trait for abstracting line representations - Added Block<S> and BlockInput<L> structs for block representation - Implemented group_lines_into_blocks() with column-aware sorting All acceptance criteria tests pass (21/21). Closes: pdftract-fy89c
20 lines
710 B
Rust
20 lines
710 B
Rust
//! Layout analysis for Phase 4.
|
|
//!
|
|
//! This module implements block-level layout analysis including:
|
|
//! - Caption classification (caption.rs)
|
|
//! - Line formation (line.rs)
|
|
//! - Readability aggregation (readability.rs)
|
|
//!
|
|
//! Phase 4 organizes extracted text into semantic blocks (paragraphs,
|
|
//! headings, figures, captions, etc.) based on spatial and font metrics.
|
|
|
|
pub mod caption;
|
|
pub mod line;
|
|
pub mod readability;
|
|
|
|
pub use caption::{classify_caption, classify_page_captions, Block, PageContext};
|
|
pub use line::{
|
|
compute_baseline, group_lines_into_blocks, union_bboxes, BlockInput, HasBBox, Line,
|
|
LineDirection, LineMetadata,
|
|
};
|
|
pub use readability::{aggregate_page_readability, ScoredSpan};
|