[go: up one dir, main page]

Extractor

Struct Extractor 

Source
pub struct Extractor { /* private fields */ }
Expand description

Extractor for extracting text from different file formats

The Extractor uses the builder pattern to set configurations. This allows configuring and extracting text in one line. For example

use extractous::{CharSet, Extractor};
let (text, metadata) = Extractor::new()
            .set_extract_string_max_length(1000)
            .extract_file_to_string("README.md")
            .unwrap();
println!("{}", text);

Implementations§

Source§

impl Extractor

Source

pub fn new() -> Self

Source

pub fn set_extract_string_max_length(self, max_length: i32) -> Self

Set the maximum length of the extracted text. Used only for extract_to_string functions Default: 500_000

Source

pub fn set_encoding(self, encoding: CharSet) -> Self

Set the encoding to use for when extracting text to a stream. Not used for extract_to_string functions. Default: CharSet::UTF_8

Source

pub fn set_pdf_config(self, config: PdfParserConfig) -> Self

Set the configuration for the PDF parser

Source

pub fn set_office_config(self, config: OfficeParserConfig) -> Self

Set the configuration for the Office parser

Source

pub fn set_ocr_config(self, config: TesseractOcrConfig) -> Self

Set the configuration for the Tesseract OCR

Source

pub fn set_xml_output(self, xml_output: bool) -> Self

Set the configuration for the parse as xml

Source

pub fn extract_file( &self, file_path: &str, ) -> ExtractResult<(StreamReader, Metadata)>

Extracts text from a file path. Returns a tuple with stream of the extracted text and metadata. the stream is decoded using the extractor’s encoding

Source

pub fn extract_bytes( &self, buffer: &[u8], ) -> ExtractResult<(StreamReader, Metadata)>

Extracts text from a byte buffer. Returns a tuple with stream of the extracted text and metadata. the stream is decoded using the extractor’s encoding

Source

pub fn extract_url(&self, url: &str) -> ExtractResult<(StreamReader, Metadata)>

Extracts text from an url. Returns a tuple with stream of the extracted text and metadata. the stream is decoded using the extractor’s encoding

Source

pub fn extract_file_to_string( &self, file_path: &str, ) -> ExtractResult<(String, Metadata)>

Extracts text from a file path. Returns a tuple with string that is of maximum length of the extractor’s extract_string_max_length and metadata.

Source

pub fn extract_bytes_to_string( &self, buffer: &[u8], ) -> ExtractResult<(String, Metadata)>

Extracts text from a byte buffer. Returns a tuple with string that is of maximum length of the extractor’s extract_string_max_length and metadata.

Source

pub fn extract_url_to_string( &self, url: &str, ) -> ExtractResult<(String, Metadata)>

Extracts text from a URL. Returns a tuple with string that is of maximum length of the extractor’s extract_string_max_length and metadata.

Trait Implementations§

Source§

impl Clone for Extractor

Source§

fn clone(&self) -> Extractor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Extractor

Source§

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

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

impl Default for Extractor

Source§

fn default() -> Self

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

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> 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, 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.