pub struct HOCR {
pub system: String,
pub capabilities: Vec<String>,
pub number_of_pages: Option<u32>,
pub langs: Option<Vec<String>>,
pub scripts: Option<Vec<String>>,
pub elements: Vec<Element>,
}
Expand description
Represents a hOCR file.
Fields§
§system: String
§capabilities: Vec<String>
§number_of_pages: Option<u32>
§langs: Option<Vec<String>>
§scripts: Option<Vec<String>>
§elements: Vec<Element>
Implementations§
Source§impl HOCR
impl HOCR
Sourcepub fn iter(&self) -> ElementsIterator<'_>
pub fn iter(&self) -> ElementsIterator<'_>
Returns an iterator over all elements in the hOCR document. Note that the iterator returns elements in a breadth-first order.
Examples found in repository?
examples/parse.rs (line 12)
3fn main() -> hocr_parser::Result<()> {
4 let xml_str = std::fs::read_to_string("examples/data/paper-image.hocr").unwrap();
5 let hocr = HOCR::from_str(&xml_str)?;
6
7 println!("OCR System: {}", &hocr.system);
8 println!("Capabilities: {:?}", &hocr.capabilities);
9 println!("Number of Pages: {:?}", &hocr.number_of_pages);
10 println!("Langs: {:?}", &hocr.langs);
11 println!("Scripts: {:?}", &hocr.scripts);
12 println!("# of Elements: {}", hocr.iter().count());
13
14 Ok(())
15}
Source§impl HOCR
impl HOCR
Sourcepub fn from_str(xml_str: &str) -> Result<Self>
pub fn from_str(xml_str: &str) -> Result<Self>
Create a new HOCR
instance from a string containing hOCR XML.
Examples found in repository?
examples/parse.rs (line 5)
3fn main() -> hocr_parser::Result<()> {
4 let xml_str = std::fs::read_to_string("examples/data/paper-image.hocr").unwrap();
5 let hocr = HOCR::from_str(&xml_str)?;
6
7 println!("OCR System: {}", &hocr.system);
8 println!("Capabilities: {:?}", &hocr.capabilities);
9 println!("Number of Pages: {:?}", &hocr.number_of_pages);
10 println!("Langs: {:?}", &hocr.langs);
11 println!("Scripts: {:?}", &hocr.scripts);
12 println!("# of Elements: {}", hocr.iter().count());
13
14 Ok(())
15}
Sourcepub fn from_hocr_borrowed(hocr: HOCRBorrowed<'_>) -> Self
pub fn from_hocr_borrowed(hocr: HOCRBorrowed<'_>) -> Self
Create a new HOCR
instance from a HOCRBorrowed
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HOCR
impl RefUnwindSafe for HOCR
impl Send for HOCR
impl Sync for HOCR
impl Unpin for HOCR
impl UnwindSafe for HOCR
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
Mutably borrows from an owned value. Read more