pub struct Track {
pub id: TrackId,
pub signals: Vec<SignalRef>,
pub entity_type: Option<TypeLabel>,
pub canonical_surface: String,
pub identity_id: Option<IdentityId>,
pub cluster_confidence: f32,
pub embedding: Option<Vec<f32>>,
}Expand description
A track: a cluster of signals referring to the same entity within a document.
§Terminology Mapping
| Vision | NLP |
|---|---|
| Tracklet | CorefChain |
| Object track | Entity cluster |
| Re-identification | Coreference resolution |
§Design Philosophy
Tracks are the bridge between raw signals and global identities. They answer: “which signals in THIS document refer to the same entity?”
Key properties:
- Document-scoped: A track only exists within one document
- Homogeneous type: All signals in a track should have compatible types
- Representative: The track has a “canonical” signal (usually the first proper mention)
Fields§
§id: TrackIdUnique identifier within the document
signals: Vec<SignalRef>Signal references in this track (document order)
entity_type: Option<TypeLabel>Entity type (consensus from signals).
This is a TypeLabel to support both core taxonomy types and domain-specific labels.
canonical_surface: StringCanonical surface form (the “best” name for this entity)
identity_id: Option<IdentityId>Link to global identity (Level 3), if resolved
cluster_confidence: f32Confidence that signals are correctly clustered
embedding: Option<Vec<f32>>Optional embedding for track-level representation (aggregated from signal embeddings)
Implementations§
Source§impl Track
impl Track
Sourcepub fn new(
id: impl Into<TrackId>,
canonical_surface: impl Into<String>,
) -> Track
pub fn new( id: impl Into<TrackId>, canonical_surface: impl Into<String>, ) -> Track
Create a new track.
Sourcepub fn add_signal(&mut self, signal_id: impl Into<SignalId>, position: u32)
pub fn add_signal(&mut self, signal_id: impl Into<SignalId>, position: u32)
Add a signal to this track.
Sourcepub fn is_singleton(&self) -> bool
pub fn is_singleton(&self) -> bool
Check if this is a singleton (single mention).
Sourcepub fn canonical_surface(&self) -> &str
pub fn canonical_surface(&self) -> &str
Get the canonical surface form.
Sourcepub const fn identity_id(&self) -> Option<IdentityId>
pub const fn identity_id(&self) -> Option<IdentityId>
Get the linked identity ID, if any.
Sourcepub const fn cluster_confidence(&self) -> f32
pub const fn cluster_confidence(&self) -> f32
Get the cluster confidence score.
Sourcepub fn set_cluster_confidence(&mut self, confidence: f32)
pub fn set_cluster_confidence(&mut self, confidence: f32)
Set the cluster confidence score.
Sourcepub fn set_identity_id(&mut self, identity_id: IdentityId)
pub fn set_identity_id(&mut self, identity_id: IdentityId)
Link this track to a global identity (mutable setter).
Sourcepub fn clear_identity_id(&mut self)
pub fn clear_identity_id(&mut self)
Unlink this track from its identity.
Sourcepub fn with_identity(self, identity_id: IdentityId) -> Track
pub fn with_identity(self, identity_id: IdentityId) -> Track
Link this track to a global identity.
Sourcepub fn with_type(self, entity_type: impl Into<String>) -> Track
pub fn with_type(self, entity_type: impl Into<String>) -> Track
Set the entity type from a string.
For new code, prefer Self::with_type_label which provides type safety.
Sourcepub fn with_type_label(self, label: TypeLabel) -> Track
pub fn with_type_label(self, label: TypeLabel) -> Track
Set the entity type using a type-safe label.
This is the preferred method for new code as it provides type safety
and integrates with the core EntityType taxonomy.
§Example
use anno_core::core::grounded::Track;
use anno_core::core::types::TypeLabel;
use anno_core::EntityType;
let track = Track::new(0, "Marie Curie")
.with_type_label(TypeLabel::Core(EntityType::Person));Sourcepub fn type_label(&self) -> Option<TypeLabel>
pub fn type_label(&self) -> Option<TypeLabel>
Get the entity type as a type-safe label.
This converts the internal string representation to a TypeLabel,
attempting to parse it as a core EntityType first.
Sourcepub fn with_embedding(self, embedding: Vec<f32>) -> Track
pub fn with_embedding(self, embedding: Vec<f32>) -> Track
Set the embedding for this track.
Sourcepub fn compute_spread(&self, doc: &GroundedDocument) -> Option<usize>
pub fn compute_spread(&self, doc: &GroundedDocument) -> Option<usize>
Get the spread (distance from first to last mention).
Requires document to resolve signal positions.
Sourcepub fn collect_variations(&self, doc: &GroundedDocument) -> Vec<String>
pub fn collect_variations(&self, doc: &GroundedDocument) -> Vec<String>
Collect all surface form variations from signals.
Requires document to resolve signal surfaces.
Sourcepub fn confidence_stats(
&self,
doc: &GroundedDocument,
) -> Option<(f32, f32, f32)>
pub fn confidence_stats( &self, doc: &GroundedDocument, ) -> Option<(f32, f32, f32)>
Get confidence statistics across all signals.
Returns (min, max, mean) confidence values.
Sourcepub fn compute_stats(
&self,
doc: &GroundedDocument,
text_len: usize,
) -> TrackStats
pub fn compute_stats( &self, doc: &GroundedDocument, text_len: usize, ) -> TrackStats
Compute aggregate statistics for this track.
Returns a TrackStats struct with comprehensive aggregate features.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Track
impl<'de> Deserialize<'de> for Track
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Track, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Track, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Track
impl Serialize for Track
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 StructuralPartialEq for Track
Auto Trait Implementations§
impl Freeze for Track
impl RefUnwindSafe for Track
impl Send for Track
impl Sync for Track
impl Unpin for Track
impl UnsafeUnpin for Track
impl UnwindSafe for Track
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<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