pub struct EntityBuilder { /* private fields */ }Expand description
Fluent builder for constructing entities with optional fields.
§Example
use anno_core::{Entity, EntityType, Provenance};
let entity = Entity::builder("Marie Curie", EntityType::Person)
.span(0, 11)
.confidence(0.95)
.kb_id("Q7186")
.provenance(Provenance::ml("bert", 0.95))
.build();Implementations§
Source§impl EntityBuilder
impl EntityBuilder
Sourcepub fn new(text: impl Into<String>, entity_type: EntityType) -> EntityBuilder
pub fn new(text: impl Into<String>, entity_type: EntityType) -> EntityBuilder
Create a new builder.
Sourcepub const fn span(self, start: usize, end: usize) -> EntityBuilder
pub const fn span(self, start: usize, end: usize) -> EntityBuilder
Set span offsets.
Sourcepub fn confidence(self, confidence: impl Into<Confidence>) -> EntityBuilder
pub fn confidence(self, confidence: impl Into<Confidence>) -> EntityBuilder
Set confidence score.
Sourcepub fn hierarchical_confidence(
self,
confidence: HierarchicalConfidence,
) -> EntityBuilder
pub fn hierarchical_confidence( self, confidence: HierarchicalConfidence, ) -> EntityBuilder
Set hierarchical confidence.
Sourcepub fn normalized(self, normalized: impl Into<String>) -> EntityBuilder
pub fn normalized(self, normalized: impl Into<String>) -> EntityBuilder
Set normalized form.
Sourcepub fn provenance(self, provenance: Provenance) -> EntityBuilder
pub fn provenance(self, provenance: Provenance) -> EntityBuilder
Set provenance.
Sourcepub fn kb_id(self, kb_id: impl Into<String>) -> EntityBuilder
pub fn kb_id(self, kb_id: impl Into<String>) -> EntityBuilder
Set knowledge base ID.
Sourcepub const fn canonical_id(self, canonical_id: u64) -> EntityBuilder
pub const fn canonical_id(self, canonical_id: u64) -> EntityBuilder
Set canonical (coreference) ID.
Sourcepub fn visual_span(self, span: Span) -> EntityBuilder
pub fn visual_span(self, span: Span) -> EntityBuilder
Set visual span.
Sourcepub fn discontinuous_span(self, span: DiscontinuousSpan) -> EntityBuilder
pub fn discontinuous_span(self, span: DiscontinuousSpan) -> EntityBuilder
Set discontinuous span for non-contiguous entities.
This automatically updates start and end to the bounding range.
Sourcepub fn mention_type(self, mention_type: MentionType) -> EntityBuilder
pub fn mention_type(self, mention_type: MentionType) -> EntityBuilder
Set mention type classification.
Trait Implementations§
Source§impl Clone for EntityBuilder
impl Clone for EntityBuilder
Source§fn clone(&self) -> EntityBuilder
fn clone(&self) -> EntityBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EntityBuilder
impl RefUnwindSafe for EntityBuilder
impl Send for EntityBuilder
impl Sync for EntityBuilder
impl Unpin for EntityBuilder
impl UnsafeUnpin for EntityBuilder
impl UnwindSafe for EntityBuilder
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