pub struct LabelNormalizer { /* private fields */ }Expand description
Normalizes entity type labels across schemas and languages.
This is a simple alias table, not a complex ontology graph. Add aliases as needed; the lookup is O(1) via HashMap.
§Example
use anno_core::core::ontology::{LabelNormalizer, CoreType};
let norm = LabelNormalizer::default();
// Different schemas resolve to same type
assert_eq!(norm.normalize("PER"), Some(CoreType::Person));
assert_eq!(norm.normalize("PERSON"), Some(CoreType::Person));
assert_eq!(norm.normalize("B-PER"), Some(CoreType::Person)); // BIO prefix stripped
// Cross-lingual
assert_eq!(norm.normalize("personne"), Some(CoreType::Person)); // FrenchImplementations§
Source§impl LabelNormalizer
impl LabelNormalizer
Sourcepub fn new() -> LabelNormalizer
pub fn new() -> LabelNormalizer
Create empty normalizer (no aliases registered).
Sourcepub fn register_many(&self, aliases: &[&str], core_type: CoreType)
pub fn register_many(&self, aliases: &[&str], core_type: CoreType)
Register multiple aliases for a core type.
Sourcepub fn normalize(&self, label: &str) -> Option<CoreType>
pub fn normalize(&self, label: &str) -> Option<CoreType>
Normalize a label to its core type.
Handles BIO/BIOES prefixes automatically.
Sourcepub fn register_biomedical(&self)
pub fn register_biomedical(&self)
Register biomedical domain types.
These are kept separate because they’re domain-specific and shouldn’t pollute the core type namespace.
Sourcepub fn register_legal(&self)
pub fn register_legal(&self)
Register legal domain types.
Sourcepub fn all_aliases(&self) -> Vec<(String, CoreType)>
pub fn all_aliases(&self) -> Vec<(String, CoreType)>
Get all known aliases (for debugging/documentation).
Trait Implementations§
Source§impl Default for LabelNormalizer
impl Default for LabelNormalizer
Source§fn default() -> LabelNormalizer
fn default() -> LabelNormalizer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for LabelNormalizer
impl RefUnwindSafe for LabelNormalizer
impl Send for LabelNormalizer
impl Sync for LabelNormalizer
impl Unpin for LabelNormalizer
impl UnsafeUnpin for LabelNormalizer
impl UnwindSafe for LabelNormalizer
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