Skip to main content

ConversionReport

Struct ConversionReport 

Source
pub struct ConversionReport {
    pub pages: usize,
    pub extracted_words: usize,
    pub rendered_words: usize,
    pub extracted_chars: usize,
    pub rendered_chars: usize,
    pub headings_found: usize,
    pub lists_found: usize,
    pub tables_found: usize,
    pub citations_found: usize,
    pub per_page: Vec<PageRecovery>,
}
Expand description

Audits one PDF-to-Markdown conversion: how much of the extracted text survived into the rendered output, plus a tally of the structural blocks found, so every conversion is auditable rather than a silent best-effort guess.

Fields§

§pages: usize§extracted_words: usize

split_whitespace().count() word totals, kept for diagnostics only. Do not use these to judge recovery – hyphenation repair, OCR word-gap merges, and table-cell tokenization all legitimately shift word counts by several percent with zero content loss, which made this ratio produce false FAILs on real documents (kopitiam-wwr). ConversionReport::recovery_ratio is the authoritative signal; these fields exist so a human auditing a report still has the raw word counts to look at.

§rendered_words: usize§extracted_chars: usize

Non-whitespace character totals underlying the headline recovery_ratio. extracted_chars counts every TextSpan on every page (soft line-wrap hyphens excluded, see is_wrap_hyphen); rendered_chars counts the rendered Markdown after strip_rendered_markdown_syntax removes syntax the renderer added (heading hashes, list markers, table pipes/separators, blockquote markers, code fences, the figure placeholder).

§rendered_chars: usize§headings_found: usize§lists_found: usize§tables_found: usize§citations_found: usize§per_page: Vec<PageRecovery>

Per-page character recovery, one entry per source page, in page order. Populated only when the Document carries page provenance (Document::block_pages); empty otherwise (a hand-built document has no page to attribute content to, and guessing would be dishonest). See PageRecovery.

Implementations§

Source§

impl ConversionReport

Source

pub fn recovery_ratio(&self) -> f64

The authoritative recovery signal: rendered_chars / extracted_chars, both counted as non-whitespace characters after normalizing away renderer-added Markdown syntax and PDF line-wrap hyphenation artifacts (see extracted_content_chars and strip_rendered_markdown_syntax in validation::mod).

What this can detect: content that was extracted from the PDF but never made it into the rendered Markdown – a dropped paragraph, a truncated table, a figure caption that got lost. A character deficit of any size shows up directly as a ratio below 1.0, because unlike a word count, non-whitespace character count cannot be inflated or deflated by re-tokenizing the same content differently.

What this cannot detect: content that survived but was corrupted or reordered – garbled characters from a bad font mapping, two paragraphs swapped, a table’s rows shuffled, a heading demoted to body text. All of those preserve the character count while changing or misplacing the content, so this ratio stays at ~100% and reports PASS regardless. This metric answers “did we lose content?”, not “is the rendered document correct?” – correctness still requires the structural tallies below and, ultimately, human review.

Source

pub fn word_recovery_ratio(&self) -> f64

Secondary, informational-only word-count ratio. See the field docs on extracted_words for why this is not used for PASS/FAIL: it is reported so a human can still see it, not because it is trustworthy on its own.

Source

pub fn passes(&self) -> bool

PASS/FAIL against [MIN_RECOVERY_RATIO], using the character-based recovery_ratio – never the word-count ratio, which is informational only (see kopitiam-wwr).

Trait Implementations§

Source§

impl Clone for ConversionReport

Source§

fn clone(&self) -> ConversionReport

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 ConversionReport

Source§

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

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

impl Default for ConversionReport

Source§

fn default() -> ConversionReport

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

impl Display for ConversionReport

Source§

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

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

impl PartialEq for ConversionReport

Source§

fn eq(&self, other: &ConversionReport) -> 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 ConversionReport

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<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<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> 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<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.