pub struct OcrTextFragment {
pub text: String,
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
pub confidence: f64,
pub word_confidences: Option<Vec<WordConfidence>>,
pub font_size: f64,
pub fragment_type: FragmentType,
}Expand description
Text fragment extracted by OCR with position and confidence information
Fields§
§text: StringThe extracted text content
x: f64X position in page coordinates (points)
y: f64Y position in page coordinates (points)
width: f64Width of the text fragment (points)
height: f64Height of the text fragment (points)
confidence: f64Confidence score for this fragment (0.0 to 1.0)
word_confidences: Option<Vec<WordConfidence>>Word-level confidence scores (optional, for advanced OCR engines)
font_size: f64Font size estimation (points)
fragment_type: FragmentTypeWhether this fragment is part of a word or line
Implementations§
Source§impl OcrTextFragment
impl OcrTextFragment
Sourcepub fn new(
text: String,
x: f64,
y: f64,
width: f64,
height: f64,
confidence: f64,
font_size: f64,
fragment_type: FragmentType,
) -> Self
pub fn new( text: String, x: f64, y: f64, width: f64, height: f64, confidence: f64, font_size: f64, fragment_type: FragmentType, ) -> Self
Create a new OCR text fragment
Sourcepub fn with_word_confidences(
text: String,
x: f64,
y: f64,
width: f64,
height: f64,
confidence: f64,
font_size: f64,
fragment_type: FragmentType,
word_confidences: Vec<WordConfidence>,
) -> Self
pub fn with_word_confidences( text: String, x: f64, y: f64, width: f64, height: f64, confidence: f64, font_size: f64, fragment_type: FragmentType, word_confidences: Vec<WordConfidence>, ) -> Self
Create a fragment with word-level confidence scores
Sourcepub fn get_low_confidence_words(&self, threshold: f64) -> Vec<&WordConfidence>
pub fn get_low_confidence_words(&self, threshold: f64) -> Vec<&WordConfidence>
Get words with confidence below the threshold
Sourcepub fn average_word_confidence(&self) -> Option<f64>
pub fn average_word_confidence(&self) -> Option<f64>
Get the average word confidence if available
Sourcepub fn words_by_confidence(&self) -> Vec<&WordConfidence>
pub fn words_by_confidence(&self) -> Vec<&WordConfidence>
Get words sorted by confidence (lowest first)
Sourcepub fn has_low_confidence_words(&self, threshold: f64) -> bool
pub fn has_low_confidence_words(&self, threshold: f64) -> bool
Check if this fragment has any low-confidence words
Sourcepub fn get_correction_candidates(
&self,
threshold: f64,
) -> Vec<CorrectionCandidate>
pub fn get_correction_candidates( &self, threshold: f64, ) -> Vec<CorrectionCandidate>
Get words that are candidates for correction (low confidence + patterns)
Sourcepub fn confidence_report(&self) -> String
pub fn confidence_report(&self) -> String
Generate a confidence report for this fragment
Trait Implementations§
Source§impl Clone for OcrTextFragment
impl Clone for OcrTextFragment
Source§fn clone(&self) -> OcrTextFragment
fn clone(&self) -> OcrTextFragment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more