pub struct PatternRecognizer { /* private fields */ }Expand description
Pattern-based recognizer using regex
Implementations§
Source§impl PatternRecognizer
impl PatternRecognizer
Sourcepub fn with_name(name: impl Into<String>) -> Self
pub fn with_name(name: impl Into<String>) -> Self
Create a new pattern recognizer with custom name
Sourcepub fn with_min_score(self, min_score: f32) -> Self
pub fn with_min_score(self, min_score: f32) -> Self
Set minimum confidence score
Sourcepub fn add_pattern(
&mut self,
entity_type: EntityType,
pattern: &str,
score: f32,
) -> Result<()>
pub fn add_pattern( &mut self, entity_type: EntityType, pattern: &str, score: f32, ) -> Result<()>
Add a custom pattern for an entity type
Sourcepub fn add_pattern_with_context(
&mut self,
entity_type: EntityType,
pattern: &str,
score: f32,
context_words: Vec<String>,
) -> Result<()>
pub fn add_pattern_with_context( &mut self, entity_type: EntityType, pattern: &str, score: f32, context_words: Vec<String>, ) -> Result<()>
Add a pattern with context words for score boosting
Trait Implementations§
Source§impl Clone for PatternRecognizer
impl Clone for PatternRecognizer
Source§fn clone(&self) -> PatternRecognizer
fn clone(&self) -> PatternRecognizer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PatternRecognizer
impl Debug for PatternRecognizer
Source§impl Default for PatternRecognizer
impl Default for PatternRecognizer
Source§impl Recognizer for PatternRecognizer
impl Recognizer for PatternRecognizer
Source§fn supported_entities(&self) -> &[EntityType]
fn supported_entities(&self) -> &[EntityType]
Get the entity types this recognizer can detect
Source§fn analyze(&self, text: &str, _language: &str) -> Result<Vec<RecognizerResult>>
fn analyze(&self, text: &str, _language: &str) -> Result<Vec<RecognizerResult>>
Analyze text and return detected entities
Source§fn supports_language(&self, language: &str) -> bool
fn supports_language(&self, language: &str) -> bool
Check if this recognizer supports the given language
Auto Trait Implementations§
impl Freeze for PatternRecognizer
impl RefUnwindSafe for PatternRecognizer
impl Send for PatternRecognizer
impl Sync for PatternRecognizer
impl Unpin for PatternRecognizer
impl UnwindSafe for PatternRecognizer
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