pub struct AdaptiveThresholdConfig {
pub median_multiplier: f32,
pub min_threshold_pt: f32,
pub max_threshold_pt: f32,
pub use_iqr: bool,
pub min_samples: usize,
}Expand description
Configuration for adaptive threshold calculation.
Determines how the threshold is computed from gap statistics. All point values assume PDF points (1/72 inch).
Fields§
§median_multiplier: f32Multiplier applied to median gap when computing threshold.
Default: 1.5 Range: 0.5 - 3.0 (values outside this may be unreasonable)
Higher values → more conservative (fewer gaps marked as word boundaries) Lower values → more aggressive (more gaps marked as word boundaries)
min_threshold_pt: f32Minimum threshold in PDF points (floor).
Default: 0.05pt (very small, close to tracking/kerning) Range: 0.01 - 0.2pt
Prevents threshold from becoming too small even with small median gaps.
max_threshold_pt: f32Maximum threshold in PDF points (ceiling).
Default: 1.0pt (about 1/72 inch, reasonable word spacing) Range: 0.5 - 2.0pt
Prevents threshold from becoming unreasonably large.
use_iqr: boolUse IQR instead of median for robust threshold calculation.
Default: false
When true: threshold = (p75 - p25) * multiplier
When false: threshold = median * multiplier
IQR-based approach is more robust to outliers but may require different multiplier values (typically 0.3 - 0.7).
min_samples: usizeMinimum number of samples required to compute meaningful statistics.
Default: 10
If fewer gaps exist, statistics cannot be reliably computed and the function returns a default threshold instead.
Implementations§
Source§impl AdaptiveThresholdConfig
impl AdaptiveThresholdConfig
Sourcepub fn balanced() -> Self
pub fn balanced() -> Self
Balanced configuration (default multiplier: 1.5).
Suitable for most PDF documents with standard spacing.
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Aggressive configuration (lower multiplier: 1.2).
Marks more gaps as word boundaries. Useful when:
- Text has tight spacing
- You want to break up large blocks more aggressively
- False negatives (missed gaps) are worse than false positives
Sourcepub fn conservative() -> Self
pub fn conservative() -> Self
Conservative configuration (higher multiplier: 2.0).
Marks fewer gaps as word boundaries. Useful when:
- Text has loose spacing
- You want to avoid breaking up tightly-kerned text
- False positives (extra gaps) are worse than false negatives
Sourcepub fn policy_documents() -> Self
pub fn policy_documents() -> Self
Optimized for policy documents with tight spacing (multiplier: 1.3).
Policy documents often have:
- Narrow margins
- Tight justified alignment
- Minimal word spacing
This configuration requires larger gaps to be detected as boundaries, and sets higher minimum threshold to avoid false positives.
Sourcepub fn academic() -> Self
pub fn academic() -> Self
Optimized for academic papers with standard spacing (multiplier: 1.6).
Academic papers typically have:
- Standard margins
- Generous word spacing
- Single or double-column layouts
This configuration is slightly more conservative than balanced to handle the higher baseline spacing.
Sourcepub fn with_multiplier(multiplier: f32) -> Self
pub fn with_multiplier(multiplier: f32) -> Self
Sourcepub fn with_min_threshold(self, min_pt: f32) -> Self
pub fn with_min_threshold(self, min_pt: f32) -> Self
Set minimum threshold floor.
Sourcepub fn with_max_threshold(self, max_pt: f32) -> Self
pub fn with_max_threshold(self, max_pt: f32) -> Self
Set maximum threshold ceiling.
Sourcepub fn with_min_samples(self, count: usize) -> Self
pub fn with_min_samples(self, count: usize) -> Self
Set minimum number of samples required.
Trait Implementations§
Source§impl Clone for AdaptiveThresholdConfig
impl Clone for AdaptiveThresholdConfig
Source§fn clone(&self) -> AdaptiveThresholdConfig
fn clone(&self) -> AdaptiveThresholdConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AdaptiveThresholdConfig
impl Debug for AdaptiveThresholdConfig
Source§impl Default for AdaptiveThresholdConfig
impl Default for AdaptiveThresholdConfig
Source§impl PartialEq for AdaptiveThresholdConfig
impl PartialEq for AdaptiveThresholdConfig
impl StructuralPartialEq for AdaptiveThresholdConfig
Auto Trait Implementations§
impl Freeze for AdaptiveThresholdConfig
impl RefUnwindSafe for AdaptiveThresholdConfig
impl Send for AdaptiveThresholdConfig
impl Sync for AdaptiveThresholdConfig
impl Unpin for AdaptiveThresholdConfig
impl UnsafeUnpin for AdaptiveThresholdConfig
impl UnwindSafe for AdaptiveThresholdConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.