Skip to main content

Track

Struct Track 

Source
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

VisionNLP
TrackletCorefChain
Object trackEntity cluster
Re-identificationCoreference 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: TrackId

Unique 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: String

Canonical surface form (the “best” name for this entity)

§identity_id: Option<IdentityId>

Link to global identity (Level 3), if resolved

§cluster_confidence: f32

Confidence that signals are correctly clustered

§embedding: Option<Vec<f32>>

Optional embedding for track-level representation (aggregated from signal embeddings)

Implementations§

Source§

impl Track

Source

pub fn new( id: impl Into<TrackId>, canonical_surface: impl Into<String>, ) -> Track

Create a new track.

Source

pub fn add_signal(&mut self, signal_id: impl Into<SignalId>, position: u32)

Add a signal to this track.

Source

pub fn len(&self) -> usize

Get the number of mentions in this track.

Source

pub fn is_empty(&self) -> bool

Check if this track is empty.

Source

pub fn is_singleton(&self) -> bool

Check if this is a singleton (single mention).

Source

pub const fn id(&self) -> TrackId

Get the track’s unique identifier.

Source

pub fn signals(&self) -> &[SignalRef]

Get the signal references in this track.

Source

pub fn canonical_surface(&self) -> &str

Get the canonical surface form.

Source

pub const fn identity_id(&self) -> Option<IdentityId>

Get the linked identity ID, if any.

Source

pub const fn cluster_confidence(&self) -> f32

Get the cluster confidence score.

Source

pub fn set_cluster_confidence(&mut self, confidence: f32)

Set the cluster confidence score.

Source

pub fn set_identity_id(&mut self, identity_id: IdentityId)

Link this track to a global identity (mutable setter).

Source

pub fn clear_identity_id(&mut self)

Unlink this track from its identity.

Source

pub fn with_identity(self, identity_id: IdentityId) -> Track

Link this track to a global identity.

Source

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.

Source

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));
Source

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.

Source

pub fn with_embedding(self, embedding: Vec<f32>) -> Track

Set the embedding for this track.

Source

pub fn compute_spread(&self, doc: &GroundedDocument) -> Option<usize>

Get the spread (distance from first to last mention).

Requires document to resolve signal positions.

Source

pub fn collect_variations(&self, doc: &GroundedDocument) -> Vec<String>

Collect all surface form variations from signals.

Requires document to resolve signal surfaces.

Source

pub fn confidence_stats( &self, doc: &GroundedDocument, ) -> Option<(f32, f32, f32)>

Get confidence statistics across all signals.

Returns (min, max, mean) confidence values.

Source

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 Clone for Track

Source§

fn clone(&self) -> Track

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Track

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Track

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Track, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Track

Source§

fn eq(&self, other: &Track) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Track

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,