Skip to main content

AdaptiveThresholdConfig

Struct AdaptiveThresholdConfig 

Source
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: f32

Multiplier 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: f32

Minimum 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: f32

Maximum 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: bool

Use 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: usize

Minimum 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

Source

pub fn new() -> Self

Create a new configuration with default values.

Source

pub fn balanced() -> Self

Balanced configuration (default multiplier: 1.5).

Suitable for most PDF documents with standard spacing.

Source

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
Source

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
Source

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.

Source

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.

Source

pub fn with_multiplier(multiplier: f32) -> Self

Create a configuration with custom multiplier.

§Arguments
  • multiplier - Multiplier for median or IQR (typically 0.5 - 3.0)
§Examples
use pdf_oxide::extractors::gap_statistics::AdaptiveThresholdConfig;

let config = AdaptiveThresholdConfig::with_multiplier(1.4);
Source

pub fn with_iqr(self, use_iqr: bool) -> Self

Enable or disable IQR-based calculation.

§Arguments
  • use_iqr - If true, use IQR instead of median
§Examples
use pdf_oxide::extractors::gap_statistics::AdaptiveThresholdConfig;

let config = AdaptiveThresholdConfig::default()
    .with_iqr(true);
Source

pub fn with_min_threshold(self, min_pt: f32) -> Self

Set minimum threshold floor.

Source

pub fn with_max_threshold(self, max_pt: f32) -> Self

Set maximum threshold ceiling.

Source

pub fn with_min_samples(self, count: usize) -> Self

Set minimum number of samples required.

Trait Implementations§

Source§

impl Clone for AdaptiveThresholdConfig

Source§

fn clone(&self) -> AdaptiveThresholdConfig

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 AdaptiveThresholdConfig

Source§

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

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

impl Default for AdaptiveThresholdConfig

Source§

fn default() -> Self

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

impl PartialEq for AdaptiveThresholdConfig

Source§

fn eq(&self, other: &AdaptiveThresholdConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AdaptiveThresholdConfig

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Ungil for T
where T: Send,