mod config;
mod gaps;
mod rows;
mod segment;
mod table;
mod types;
pub use config::SegmentParams;
pub use segment::segment;
pub use types::{BBox, Bounded, SplitDir, Zone};
#[cfg(test)]
pub(crate) mod test_support {
use super::SegmentParams;
use super::types::{BBox, Bounded};
#[derive(Debug, Clone)]
pub(crate) struct Item {
pub bbox: BBox,
pub chars: usize,
}
impl Bounded for Item {
fn bbox(&self) -> BBox {
self.bbox
}
fn char_count(&self) -> usize {
self.chars
}
}
pub(crate) fn b(left: f32, bottom: f32, right: f32, top: f32) -> Item {
let width = (right - left).max(0.0);
let chars = if width <= 0.0 {
0
} else {
(width / 5.0).round().max(0.0) as usize
};
Item {
bbox: BBox {
left,
right,
bottom,
top,
},
chars,
}
}
pub(crate) fn b_chars(left: f32, bottom: f32, right: f32, top: f32, chars: usize) -> Item {
Item {
bbox: BBox {
left,
right,
bottom,
top,
},
chars,
}
}
pub(crate) fn params() -> SegmentParams {
SegmentParams {
min_v_gap: 5.0,
min_h_gap: 5.0,
min_zone_items: 2,
table_regions: Vec::new(),
}
}
}