pub struct NerRecognizer { /* private fields */ }Expand description
NER-based recognizer using ONNX Runtime
Status: ✅ Fully operational with complete ONNX Runtime integration
This recognizer uses transformer-based Named Entity Recognition models for contextual PII detection. It automatically loads and runs ONNX models with:
- Tokenization with HuggingFace tokenizers
- ONNX Runtime inference with optimizations
- BIO tag parsing for entity span extraction
- Thread-safe session management
To enable NER:
- Export your NER model to ONNX format using
scripts/export_ner_model.py - Set
model_pathto point to your.onnxfile - Optionally provide
tokenizer_pathor placetokenizer.jsonin the same directory
Without a model, this recognizer gracefully returns empty results and the system falls back to pattern-based detection (36+ entity types).
Implementations§
Source§impl NerRecognizer
impl NerRecognizer
Sourcepub fn from_file<P: AsRef<Path>>(model_path: P) -> Result<Self>
pub fn from_file<P: AsRef<Path>>(model_path: P) -> Result<Self>
Create a new NER recognizer from a model file
Sourcepub fn from_config(config: NerConfig) -> Result<Self>
pub fn from_config(config: NerConfig) -> Result<Self>
Create a new NER recognizer from configuration
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Check if NER is available (model and tokenizer loaded)
Trait Implementations§
Source§impl Debug for NerRecognizer
impl Debug for NerRecognizer
Source§impl Recognizer for NerRecognizer
impl Recognizer for NerRecognizer
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 NerRecognizer
impl RefUnwindSafe for NerRecognizer
impl Send for NerRecognizer
impl Sync for NerRecognizer
impl Unpin for NerRecognizer
impl UnwindSafe for NerRecognizer
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
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>
Converts
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>
Converts
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 more