pub struct LabelMap(pub BTreeMap<String, PiiClass>);Expand description
Labels file format.
Accepts two equivalent shapes so adopters aren’t silently blocked by a keying convention mismatch:
- Bare entity keys (preferred, short):
{ "PER": "Name", "LOC": "Location" }. - BIO-prefixed keys (mirrors CoNLL / HuggingFace
id2labelshape):{ "B-PER": "Name", "I-PER": "Name", "B-LOC": "Location", "I-LOC": "Location" }.
Values are matched against PiiClass variants by lowercase name, falling
back to PiiClass::custom(value) if no built-in matches. The sentinel
value "drop" (or "ignore", "") removes the entry entirely so the
detector silently skips that label.
Lookup (resolve) tries the full BIO tag first, then the bare entity
type. Mixing both key shapes in a single file is allowed.
Tuple Fields§
§0: BTreeMap<String, PiiClass>Implementations§
Source§impl LabelMap
impl LabelMap
pub fn get(&self, conll_label: &str) -> Option<&PiiClass>
Sourcepub fn resolve(&self, tag: &str, entity: &str) -> Option<&PiiClass>
pub fn resolve(&self, tag: &str, entity: &str) -> Option<&PiiClass>
Resolve a CoNLL subword tag (e.g. "B-PER", "I-LOC", "PER") to a
PiiClass. Accepts both BIO-prefixed labels.json entries and bare
entity-type entries; tries the full tag first, then the stripped
entity.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of retained mappings (after "drop"/"ignore" sentinels are
filtered out by the parser). Used by the NER bootstrap tracing::info!
so adopters can tell at a glance whether their labels.json is empty
or misaligned.
pub fn is_empty(&self) -> bool
Trait Implementations§
impl Eq for LabelMap
impl StructuralPartialEq for LabelMap
Auto Trait Implementations§
impl Freeze for LabelMap
impl RefUnwindSafe for LabelMap
impl Send for LabelMap
impl Sync for LabelMap
impl Unpin for LabelMap
impl UnsafeUnpin for LabelMap
impl UnwindSafe for LabelMap
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
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
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>
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>
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