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>) -> Self
pub fn new(id: impl Into<TrackId>, canonical_surface: impl Into<String>) -> Self
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) -> Self
pub fn with_identity(self, identity_id: IdentityId) -> Self
Link this track to a global identity.
Sourcepub fn with_type(self, entity_type: impl Into<String>) -> Self
pub fn with_type(self, entity_type: impl Into<String>) -> Self
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) -> Self
pub fn with_type_label(self, label: TypeLabel) -> Self
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>) -> Self
pub fn with_embedding(self, embedding: Vec<f32>) -> Self
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.