pub trait EntitySliceExt {
Show 13 methods
// Required methods
fn above_confidence(&self, min: f64) -> impl Iterator<Item = &Entity>;
fn of_type(&self, ty: &EntityType) -> impl Iterator<Item = &Entity>;
fn has_overlaps(&self) -> bool;
fn overlapping_pairs(&self) -> Vec<(&Entity, &Entity)>;
fn sorted_by_confidence(&self) -> Vec<&Entity>;
fn sorted_by_position(&self) -> Vec<&Entity>;
fn highest_confidence(&self) -> Option<&Entity>;
fn mean_confidence(&self) -> Option<f64>;
fn group_by_type(&self) -> HashMap<String, Vec<&Entity>>;
fn contains_position(&self, pos: usize) -> bool;
fn at_position(&self, pos: usize) -> Option<&Entity>;
fn named_only(&self) -> impl Iterator<Item = &Entity>;
fn structured_only(&self) -> impl Iterator<Item = &Entity>;
}Expand description
Extension methods for slices of entities.
This trait adds useful operations to [Entity] and Vec<Entity>
without requiring you to wrap them in a newtype.
§Example
use anno::{Entity, EntityType};
use anno::types::EntitySliceExt;
let entities = vec![
Entity::new("John", EntityType::Person, 0, 4, 0.9),
Entity::new("$100", EntityType::Money, 10, 14, 0.95),
Entity::new("Paris", EntityType::Location, 20, 25, 0.7),
];
// Filter by confidence
let high_conf: Vec<_> = entities.above_confidence(0.8).collect();
assert_eq!(high_conf.len(), 2);
// Check for overlaps
assert!(!entities.has_overlaps());Required Methods§
Sourcefn above_confidence(&self, min: f64) -> impl Iterator<Item = &Entity>
fn above_confidence(&self, min: f64) -> impl Iterator<Item = &Entity>
Filter entities by minimum confidence threshold.
Sourcefn of_type(&self, ty: &EntityType) -> impl Iterator<Item = &Entity>
fn of_type(&self, ty: &EntityType) -> impl Iterator<Item = &Entity>
Filter entities by type.
Sourcefn has_overlaps(&self) -> bool
fn has_overlaps(&self) -> bool
Check if any entities overlap with each other.
Sourcefn overlapping_pairs(&self) -> Vec<(&Entity, &Entity)>
fn overlapping_pairs(&self) -> Vec<(&Entity, &Entity)>
Find all overlapping pairs of entities.
Sourcefn sorted_by_confidence(&self) -> Vec<&Entity>
fn sorted_by_confidence(&self) -> Vec<&Entity>
Get entities sorted by confidence (descending).
Sourcefn sorted_by_position(&self) -> Vec<&Entity>
fn sorted_by_position(&self) -> Vec<&Entity>
Get entities sorted by position (ascending).
Sourcefn highest_confidence(&self) -> Option<&Entity>
fn highest_confidence(&self) -> Option<&Entity>
Get the entity with highest confidence.
Sourcefn mean_confidence(&self) -> Option<f64>
fn mean_confidence(&self) -> Option<f64>
Calculate average confidence across all entities.
Sourcefn contains_position(&self, pos: usize) -> bool
fn contains_position(&self, pos: usize) -> bool
Check if a position falls within any entity span.
Sourcefn at_position(&self, pos: usize) -> Option<&Entity>
fn at_position(&self, pos: usize) -> Option<&Entity>
Get entity at a specific position (if any).
Sourcefn named_only(&self) -> impl Iterator<Item = &Entity>
fn named_only(&self) -> impl Iterator<Item = &Entity>
Filter to only named entities (Person, Org, Location).
Sourcefn structured_only(&self) -> impl Iterator<Item = &Entity>
fn structured_only(&self) -> impl Iterator<Item = &Entity>
Filter to only structured entities (Date, Money, Email, etc.).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.