pub struct Corpus { /* private fields */ }Expand description
A corpus of grounded documents for cross-document operations.
Enables inter-document coreference resolution and entity linking across multiple documents.
Implementations§
Source§impl Corpus
impl Corpus
Sourcepub fn identities(&self) -> &HashMap<IdentityId, Identity>
pub fn identities(&self) -> &HashMap<IdentityId, Identity>
Get all identities in the corpus.
Sourcepub fn get_identity(&self, id: IdentityId) -> Option<&Identity>
pub fn get_identity(&self, id: IdentityId) -> Option<&Identity>
Get an identity by ID.
Sourcepub fn add_identity(&mut self, identity: Identity) -> IdentityId
pub fn add_identity(&mut self, identity: Identity) -> IdentityId
Add an identity to the corpus and return its ID.
This method assigns the next available identity ID and inserts the identity. Used by coalescing operations to create cross-document identities.
Sourcepub fn next_identity_id(&self) -> IdentityId
pub fn next_identity_id(&self) -> IdentityId
Get the next identity ID that would be assigned.
This is used by coalescing operations to reserve identity IDs.
Sourcepub fn documents(&self) -> impl Iterator<Item = &GroundedDocument>
pub fn documents(&self) -> impl Iterator<Item = &GroundedDocument>
Get all documents in the corpus.
Returns an iterator over all documents.
Sourcepub fn get_document(&self, doc_id: &str) -> Option<&GroundedDocument>
pub fn get_document(&self, doc_id: &str) -> Option<&GroundedDocument>
Get a document by ID.
Returns None if the document doesn’t exist.
Sourcepub fn get_document_mut(
&mut self,
doc_id: &str,
) -> Option<&mut GroundedDocument>
pub fn get_document_mut( &mut self, doc_id: &str, ) -> Option<&mut GroundedDocument>
Get a mutable reference to a document by ID.
Returns None if the document doesn’t exist.
Sourcepub fn add_document(&mut self, document: GroundedDocument) -> String
pub fn add_document(&mut self, document: GroundedDocument) -> String
Add a document to the corpus.
If a document with the same ID already exists, it will be replaced. Returns the document ID.
Sourcepub fn link_track_to_kb(
&mut self,
track_ref: &TrackRef,
kb_name: impl Into<String>,
kb_id: impl Into<String>,
canonical_name: impl Into<String>,
) -> Result<IdentityId, Error>
pub fn link_track_to_kb( &mut self, track_ref: &TrackRef, kb_name: impl Into<String>, kb_id: impl Into<String>, canonical_name: impl Into<String>, ) -> Result<IdentityId, Error>
Link a track to a knowledge base entity.
This is the entity linking (NED) operation. It creates or updates an identity with KB information.
§Parameters
track_ref- Reference to the track to linkkb_name- Knowledge base name (e.g., “wikidata”)kb_id- Knowledge base entity ID (e.g., “Q7186”)canonical_name- Canonical name from KB
§Returns
The identity ID (new or existing), or an error if the track reference is invalid.
§Errors
Returns Error::TrackRef if:
- The document ID doesn’t exist in the corpus
- The track ID doesn’t exist in the document
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Corpus
impl RefUnwindSafe for Corpus
impl Send for Corpus
impl Sync for Corpus
impl Unpin for Corpus
impl UnsafeUnpin for Corpus
impl UnwindSafe for Corpus
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