pub struct Signal<L = Location> {
pub id: SignalId,
pub location: L,
pub surface: String,
pub label: TypeLabel,
pub confidence: f32,
pub hierarchical: Option<HierarchicalConfidence>,
pub provenance: Option<Provenance>,
pub modality: Modality,
pub normalized: Option<String>,
pub negated: bool,
pub quantifier: Option<Quantifier>,
}Expand description
A raw detection signal: the atomic unit of entity extraction.
§The Detection Equation
Every signal is the product of two factors:
Signal = Localization × Classification
= "where is it?" × "what is it?"This is true whether detecting faces in images, named entities in text, or objects in LiDAR point clouds.
§Design Philosophy
Signals are intentionally minimal. They capture:
- Where: Location in the source medium
- What: Classification label + confidence
- Provenance: How it was detected
What they explicitly do NOT capture:
- Coreference relationships (→ Track)
- Knowledge base links (→ Identity)
- Semantic embeddings (computed lazily if needed)
This separation enables efficient streaming pipelines where signals are produced incrementally and consumed by downstream track/identity formation without blocking.
Fields§
§id: SignalIdUnique identifier within the document
location: LLocation in the source medium
surface: StringSurface form (the actual text or image patch)
label: TypeLabelClassification label (e.g., “Person”, “Organization”, “PER”).
Stored as a TypeLabel to support both core taxonomy types and domain-specific labels.
confidence: f32Detection confidence in [0, 1]
hierarchical: Option<HierarchicalConfidence>Hierarchical confidence if available (linkage/type/boundary)
provenance: Option<Provenance>Provenance: which detector produced this signal
modality: ModalitySemiotic modality (derived from location, but can be overridden)
normalized: Option<String>Normalized form (e.g., “Jan 15” → “2024-01-15”)
negated: boolWhether this signal is negated (e.g., “not a doctor”)
quantifier: Option<Quantifier>Quantification if applicable (e.g., “every employee”)
Implementations§
Source§impl<L> Signal<L>
impl<L> Signal<L>
Sourcepub fn new(
id: impl Into<SignalId>,
location: L,
surface: impl Into<String>,
label: impl Into<TypeLabel>,
confidence: f32,
) -> Self
pub fn new( id: impl Into<SignalId>, location: L, surface: impl Into<String>, label: impl Into<TypeLabel>, confidence: f32, ) -> Self
Create a new signal.
§Arguments
id- Unique identifier (will be overwritten when added to a document)location- Where this signal was detectedsurface- The actual text/content of the detectionlabel- Classification label (e.g., “Person”, “Organization”)confidence- Detection confidence in[0, 1]
Sourcepub fn type_label(&self) -> TypeLabel
pub fn type_label(&self) -> TypeLabel
Get the classification label as a type-safe TypeLabel.
Sourcepub fn is_confident(&self, threshold: f32) -> bool
pub fn is_confident(&self, threshold: f32) -> bool
Check if this signal is above a confidence threshold.
Sourcepub fn with_modality(self, modality: Modality) -> Self
pub fn with_modality(self, modality: Modality) -> Self
Set the modality.
Sourcepub fn with_quantifier(self, q: Quantifier) -> Self
pub fn with_quantifier(self, q: Quantifier) -> Self
Set quantifier.
Sourcepub fn with_provenance(self, p: Provenance) -> Self
pub fn with_provenance(self, p: Provenance) -> Self
Set provenance.
Source§impl Signal<Location>
impl Signal<Location>
Sourcepub fn text_offsets(&self) -> Option<(usize, usize)>
pub fn text_offsets(&self) -> Option<(usize, usize)>
Get text offsets if this is a text signal.
Sourcepub fn validate_against(
&self,
source_text: &str,
) -> Option<SignalValidationError>
pub fn validate_against( &self, source_text: &str, ) -> Option<SignalValidationError>
Validate that this signal’s location matches its surface text.
Returns None if valid, or a description of the mismatch.
§Example
use anno_core::grounded::{Signal, Location};
let text = "Lynn Conway worked at IBM.";
let good = Signal::new(0, Location::text(0, 11), "Lynn Conway", "PER", 0.9);
assert!(good.validate_against(text).is_none());
let bad = Signal::new(0, Location::text(0, 5), "Lynn Conway", "PER", 0.9);
assert!(bad.validate_against(text).is_some());Sourcepub fn is_valid(&self, source_text: &str) -> bool
pub fn is_valid(&self, source_text: &str) -> bool
Check if this signal is valid against the given source text.
Sourcepub fn from_text(
source: &str,
surface: &str,
label: impl Into<TypeLabel>,
confidence: f32,
) -> Option<Self>
pub fn from_text( source: &str, surface: &str, label: impl Into<TypeLabel>, confidence: f32, ) -> Option<Self>
Create a signal by finding text in source (safe construction).
Returns None if the surface text is not found in source.
§Example
use anno_core::grounded::{Signal, Location};
let text = "Lynn Conway worked at IBM.";
let signal = Signal::<Location>::from_text(text, "Lynn Conway", "PER", 0.95);
assert!(signal.is_some());
assert_eq!(signal.expect("signal should exist").text_offsets(), Some((0, 11)));