pub struct MockModel { /* private fields */ }Expand description
A mock NER model for testing purposes.
This is provided so tests can create custom mock implementations without breaking the sealed trait pattern.
§Entity Validation
By default, extract_entities validates that entity offsets are within
the input text bounds and that start < end. Set validate = false
to disable this (useful for testing error handling).
§Example
use anno::{MockModel, Entity, EntityType, Result};
let mock = MockModel::new("test-mock")
.with_entities(vec![
Entity::new("John", EntityType::Person, 0, 4, 0.9),
]);
// Use mock in testsImplementations§
Source§impl MockModel
impl MockModel
Sourcepub fn with_entities(self, entities: Vec<Entity>) -> Self
pub fn with_entities(self, entities: Vec<Entity>) -> Self
Sourcepub fn with_types(self, types: Vec<EntityType>) -> Self
pub fn with_types(self, types: Vec<EntityType>) -> Self
Set supported entity types.
Sourcepub fn without_validation(self) -> Self
pub fn without_validation(self) -> Self
Disable offset validation during extraction (for testing error paths).
Trait Implementations§
Source§impl Model for MockModel
impl Model for MockModel
Source§fn extract_entities(
&self,
text: &str,
_language: Option<&str>,
) -> Result<Vec<Entity>>
fn extract_entities( &self, text: &str, _language: Option<&str>, ) -> Result<Vec<Entity>>
Extract entities from text.
Source§fn supported_types(&self) -> Vec<EntityType>
fn supported_types(&self) -> Vec<EntityType>
Get supported entity types.
Source§fn is_available(&self) -> bool
fn is_available(&self) -> bool
Check if model is available and ready.
Source§fn description(&self) -> &'static str
fn description(&self) -> &'static str
Get a description of the model.
Source§fn capabilities(&self) -> ModelCapabilities
fn capabilities(&self) -> ModelCapabilities
Get capability summary for this model. Read more
Auto Trait Implementations§
impl Freeze for MockModel
impl RefUnwindSafe for MockModel
impl Send for MockModel
impl Sync for MockModel
impl Unpin for MockModel
impl UnsafeUnpin for MockModel
impl UnwindSafe for MockModel
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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