#[non_exhaustive]pub enum EntityType {
Show 14 variants
Person,
Organization,
Location,
Date,
Time,
Money,
Percent,
Quantity,
Cardinal,
Ordinal,
Email,
Url,
Phone,
Custom {
name: String,
category: EntityCategory,
},
}Expand description
Entity type classification.
Organized into categories:
- Named (ML-required): Person, Organization, Location
- Temporal (pattern): Date, Time
- Numeric (pattern): Money, Percent, Quantity, Cardinal, Ordinal
- Contact (pattern): Email, Url, Phone
§Examples
use anno_core::EntityType;
let ty = EntityType::Email;
assert!(ty.category().pattern_detectable());
assert!(!ty.category().requires_ml());
let ty = EntityType::Person;
assert!(ty.category().requires_ml());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Person
Person name (PER) - requires ML/context
Organization
Organization name (ORG) - requires ML/context
Location
Location/Place (LOC/GPE) - requires ML/context
Date
Date expression (DATE) - pattern-detectable
Time
Time expression (TIME) - pattern-detectable
Money
Monetary value (MONEY) - pattern-detectable
Percent
Percentage (PERCENT) - pattern-detectable
Quantity
Quantity with unit (QUANTITY) - pattern-detectable
Cardinal
Cardinal number (CARDINAL) - pattern-detectable
Ordinal
Ordinal number (ORDINAL) - pattern-detectable
Email address - pattern-detectable
Url
URL/URI - pattern-detectable
Phone
Phone number - pattern-detectable
Custom
Domain-specific custom type with explicit category
Fields
category: EntityCategoryCategory for this custom type
Implementations§
Source§impl EntityType
impl EntityType
Sourcepub fn category(&self) -> EntityCategory
pub fn category(&self) -> EntityCategory
Get the category of this entity type.
Sourcepub fn requires_ml(&self) -> bool
pub fn requires_ml(&self) -> bool
Returns true if this entity type requires ML for detection.
Sourcepub fn pattern_detectable(&self) -> bool
pub fn pattern_detectable(&self) -> bool
Returns true if this entity type can be detected via patterns.
Sourcepub fn as_label(&self) -> &str
pub fn as_label(&self) -> &str
Convert to standard label string (CoNLL/OntoNotes format).
use anno_core::EntityType;
assert_eq!(EntityType::Person.as_label(), "PER");
assert_eq!(EntityType::Location.as_label(), "LOC");Sourcepub fn from_label(label: &str) -> EntityType
pub fn from_label(label: &str) -> EntityType
Parse from standard label string.
Handles various formats: CoNLL (PER), OntoNotes (PERSON), BIO (B-PER).
use anno_core::EntityType;
assert_eq!(EntityType::from_label("PER"), EntityType::Person);
assert_eq!(EntityType::from_label("B-ORG"), EntityType::Organization);
assert_eq!(EntityType::from_label("PERSON"), EntityType::Person);Sourcepub fn custom(name: impl Into<String>, category: EntityCategory) -> EntityType
pub fn custom(name: impl Into<String>, category: EntityCategory) -> EntityType
Create a custom domain-specific entity type.
§Examples
use anno_core::{EntityType, EntityCategory};
let disease = EntityType::custom("DISEASE", EntityCategory::Agent);
assert!(disease.requires_ml());
let product_id = EntityType::custom("PRODUCT_ID", EntityCategory::Misc);
assert!(!product_id.requires_ml());Trait Implementations§
Source§impl Clone for EntityType
impl Clone for EntityType
Source§fn clone(&self) -> EntityType
fn clone(&self) -> EntityType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EntityType
impl Debug for EntityType
Source§impl<'de> Deserialize<'de> for EntityType
impl<'de> Deserialize<'de> for EntityType
Source§fn deserialize<D>(
deserializer: D,
) -> Result<EntityType, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<EntityType, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for EntityType
impl Display for EntityType
Source§impl From<EntityType> for TypeLabel
impl From<EntityType> for TypeLabel
Source§fn from(et: EntityType) -> TypeLabel
fn from(et: EntityType) -> TypeLabel
Source§impl FromStr for EntityType
impl FromStr for EntityType
Source§fn from_str(s: &str) -> Result<EntityType, <EntityType as FromStr>::Err>
fn from_str(s: &str) -> Result<EntityType, <EntityType as FromStr>::Err>
Parse from standard label string. Never fails – unknown labels become Custom.
Source§type Err = Infallible
type Err = Infallible
Source§impl Hash for EntityType
impl Hash for EntityType
Source§impl PartialEq for EntityType
impl PartialEq for EntityType
Source§impl Serialize for EntityType
impl Serialize for EntityType
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for EntityType
impl StructuralPartialEq for EntityType
Auto Trait Implementations§
impl Freeze for EntityType
impl RefUnwindSafe for EntityType
impl Send for EntityType
impl Sync for EntityType
impl Unpin for EntityType
impl UnsafeUnpin for EntityType
impl UnwindSafe for EntityType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.