pub enum TextDensity {
Low,
Medium,
High,
}Expand description
CJK text density classification for adaptive scoring.
Different CJK documents have different character densities:
- Academic papers, formal documents: High density (many chars per page)
- Children’s books, sparse layouts: Low density (fewer chars per page)
- Most books: Medium density
Density affects how aggressively punctuation creates boundaries.
Variants§
Low
Low density: Sparse text with significant whitespace Example: Children’s books, formatted documents with large margins Characteristic: < 500 characters per page equivalent
Medium
Medium density: Normal text with standard spacing Example: Most books, regular documents Characteristic: 500-2000 characters per page equivalent
High
High density: Dense text with minimal whitespace Example: Academic papers, technical documents, legal text Characteristic: > 2000 characters per page equivalent
Implementations§
Source§impl TextDensity
impl TextDensity
Sourcepub fn classify(char_count: usize, page_count: usize) -> Self
pub fn classify(char_count: usize, page_count: usize) -> Self
Classify text density based on character count in a sample.
This uses a simple heuristic: count characters in a representative sample and estimate document-wide density.
§Arguments
char_count- Total characters processed so farpage_count- Number of pages processed
§Returns
Classified density level
Sourcepub fn score_multiplier(&self) -> f32
pub fn score_multiplier(&self) -> f32
Get density multiplier for adaptive scoring.
Returns a factor (0.5-1.5) to multiply base scores:
- Low density (0.6): More conservative, require higher scores for boundaries
- Medium density (1.0): No adjustment
- High density (1.4): More aggressive, lower scores trigger boundaries
Trait Implementations§
Source§impl Clone for TextDensity
impl Clone for TextDensity
Source§fn clone(&self) -> TextDensity
fn clone(&self) -> TextDensity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TextDensity
Source§impl Debug for TextDensity
impl Debug for TextDensity
impl Eq for TextDensity
Source§impl PartialEq for TextDensity
impl PartialEq for TextDensity
impl StructuralPartialEq for TextDensity
Auto Trait Implementations§
impl Freeze for TextDensity
impl RefUnwindSafe for TextDensity
impl Send for TextDensity
impl Sync for TextDensity
impl Unpin for TextDensity
impl UnsafeUnpin for TextDensity
impl UnwindSafe for TextDensity
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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<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.