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 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§
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