pub struct PatternLibrary { /* private fields */ }Expand description
Library of patterns for invoice field extraction
Implementations§
Source§impl PatternLibrary
impl PatternLibrary
Sourcepub fn with_language(lang: Language) -> Self
pub fn with_language(lang: Language) -> Self
Create a pattern library for a specific language
Sourcepub fn add_pattern(&mut self, pattern: FieldPattern)
pub fn add_pattern(&mut self, pattern: FieldPattern)
Add a pattern to the library
Sourcepub fn default_spanish() -> Self
pub fn default_spanish() -> Self
Create a pattern library with default Spanish patterns
Returns a new PatternLibrary pre-loaded with Spanish invoice patterns.
Users can add custom patterns on top of defaults using add_pattern().
§Examples
use oxidize_pdf::text::invoice::{PatternLibrary, FieldPattern, InvoiceFieldType, Language};
// Load Spanish defaults
let mut patterns = PatternLibrary::default_spanish();
// Add custom pattern for specific format
patterns.add_pattern(
FieldPattern::new(
InvoiceFieldType::InvoiceNumber,
r"Invoice\s+#\s*([0-9]+)",
0.85,
Some(Language::Spanish)
).unwrap()
);Sourcepub fn default_english() -> Self
pub fn default_english() -> Self
Create a pattern library with default English patterns
Returns a new PatternLibrary pre-loaded with English invoice patterns.
§Examples
use oxidize_pdf::text::invoice::PatternLibrary;
let patterns = PatternLibrary::default_english();Sourcepub fn default_german() -> Self
pub fn default_german() -> Self
Create a pattern library with default German patterns
Returns a new PatternLibrary pre-loaded with German invoice patterns.
§Examples
use oxidize_pdf::text::invoice::PatternLibrary;
let patterns = PatternLibrary::default_german();Sourcepub fn default_italian() -> Self
pub fn default_italian() -> Self
Create a pattern library with default Italian patterns
Returns a new PatternLibrary pre-loaded with Italian invoice patterns.
§Examples
use oxidize_pdf::text::invoice::PatternLibrary;
let patterns = PatternLibrary::default_italian();Sourcepub fn merge(&mut self, other: PatternLibrary)
pub fn merge(&mut self, other: PatternLibrary)
Merge patterns from another library into this one
Adds all patterns from other to this library. Useful for combining
default patterns with custom patterns.
§Examples
use oxidize_pdf::text::invoice::{PatternLibrary, FieldPattern, InvoiceFieldType, Language};
// Start with Spanish defaults
let mut patterns = PatternLibrary::default_spanish();
// Create custom library
let mut custom = PatternLibrary::new();
custom.add_pattern(
FieldPattern::new(
InvoiceFieldType::InvoiceNumber,
r"Ref:\s*([A-Z0-9\-]+)",
0.8,
Some(Language::Spanish)
).unwrap()
);
// Merge custom into defaults
patterns.merge(custom);Sourcepub fn match_text(&self, text: &str) -> Vec<(InvoiceFieldType, String, f64)>
pub fn match_text(&self, text: &str) -> Vec<(InvoiceFieldType, String, f64)>
Match text against all patterns
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PatternLibrary
impl RefUnwindSafe for PatternLibrary
impl Send for PatternLibrary
impl Sync for PatternLibrary
impl Unpin for PatternLibrary
impl UnwindSafe for PatternLibrary
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().