pub struct NerEngine { /* private fields */ }Expand description
NER engine wrapping gline-rs GLiNER in span mode.
Uses onnx-community/gliner_large-v2.1 (or any span-based GLiNER ONNX model).
Implementations§
Source§impl NerEngine
impl NerEngine
Sourcepub fn new(
model_path: &Path,
tokenizer_path: &Path,
threshold: f32,
) -> Result<Self, NerError>
pub fn new( model_path: &Path, tokenizer_path: &Path, threshold: f32, ) -> Result<Self, NerError>
Create a new NER engine from model and tokenizer paths.
model_path: path tomodel.onnx(ormodel_int8.onnx)tokenizer_path: path totokenizer.jsonthreshold: minimum GLiNER span probability (0.0–1.0).Parameters::defaultuses 0.5 which is too aggressive for domain-specific labels; use a lower value like 0.1–0.3 and let the pipeline apply its own threshold on top.
Sourcepub fn extract(
&self,
text: &str,
labels: &[&str],
label_to_type: Option<&HashMap<&str, &str>>,
) -> Result<Vec<ExtractedEntity>, NerError>
pub fn extract( &self, text: &str, labels: &[&str], label_to_type: Option<&HashMap<&str, &str>>, ) -> Result<Vec<ExtractedEntity>, NerError>
Extract entities from text using the given labels.
label_to_type is an optional mapping from GLiNER label string → canonical
entity type key. Pass None to use the label string as-is for entity_type.
Pass Some(pairs) when using natural-language descriptions as labels so the
returned entity_type is the short canonical key (e.g. “Database”).
Auto Trait Implementations§
impl !Freeze for NerEngine
impl !RefUnwindSafe for NerEngine
impl Send for NerEngine
impl Sync for NerEngine
impl Unpin for NerEngine
impl UnsafeUnpin for NerEngine
impl !UnwindSafe for NerEngine
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