pub enum PdfWordGap {
Legacy,
Factor(f64),
Adaptive,
}Expand description
How a word boundary is decided where the PDF draws no space glyph — a word set apart only by moving the text cursor (#921).
WordGap::Adaptive, the default, and WordGap::Factor follow
docling-parse ≥ 7’s contractor (cells.h::contract, 2026-09, PR #351 —
what docling ≥ 2.142 runs on, docling-parse>=7.22): glyphs are grouped
into line runs by geometry alone (no font boundary), every gap between
two visible glyphs is normalized by the mean advance of those two
glyphs, and a normalized gap above the threshold starts a new word; an
explicit space glyph is always a boundary. Line cells are the run’s
words joined by single spaces. Letter spacing is detected first
([tracked_gaps]) — our addition, where docling-parse cuts letter-spaced
words mid-word.
WordGap::Legacy is the contraction above: the docling-parse ≤ 6 rule
this port started from, where a gap splits two words when it exceeds
0.33 × the running mean advance of the cell accumulated so far — a cell
that restarts at every font change, so the threshold drifts along a line
(und dem in a second font resource read unddem: 1.955 pt against
0.33 × 5.925 pt, the mean of und alone).
Variants§
Legacy
docling-parse ≤ 6’s running-mean contraction.
Factor(f64)
A fixed normalized threshold for every line.
Adaptive
docling-parse ≥ 7’s line-local threshold: a two-cluster k-means over the line’s normalized gaps (character spacing vs word spacing), at least 0.18, capped at 0.35, 0.25 when the gaps do not separate.
Implementations§
Source§impl WordGap
impl WordGap
Sourcepub const ACCEPTED: &'static str = "legacy, adaptive, or a factor in (0, 4]"
pub const ACCEPTED: &'static str = "legacy, adaptive, or a factor in (0, 4]"
The accepted spellings, for error messages.
Sourcepub fn parse(s: &str) -> Result<WordGap, String>
pub fn parse(s: &str) -> Result<WordGap, String>
legacy / adaptive / a positive factor up to 4 (case-insensitive);
Err with the reason for anything else.
Sourcepub fn from_env() -> WordGap
pub fn from_env() -> WordGap
DOCLING_RS_PDF_WORD_GAP, or the default (WordGap::Adaptive)
when it is unset (an unreadable value warns once and keeps the
default).
Trait Implementations§
impl Copy for WordGap
impl StructuralPartialEq for WordGap
Auto Trait Implementations§
impl Freeze for WordGap
impl RefUnwindSafe for WordGap
impl Send for WordGap
impl Sync for WordGap
impl Unpin for WordGap
impl UnsafeUnpin for WordGap
impl UnwindSafe for WordGap
Blanket Implementations§
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
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 more