pub struct ExtractionSchema {
pub name: String,
pub entity_types: BTreeMap<String, String>,
pub relation_types: BTreeMap<String, RelationSpec>,
}Expand description
Extraction schema defining which entity types and relation types to extract.
Loaded from a ctxgraph.toml file or constructed via ExtractionSchema::default().
Fields§
§name: String§entity_types: BTreeMap<String, String>§relation_types: BTreeMap<String, RelationSpec>Implementations§
Source§impl ExtractionSchema
impl ExtractionSchema
Sourcepub fn load(path: &Path) -> Result<Self, SchemaError>
pub fn load(path: &Path) -> Result<Self, SchemaError>
Load schema from a TOML file.
Sourcepub fn from_toml(content: &str) -> Result<Self, SchemaError>
pub fn from_toml(content: &str) -> Result<Self, SchemaError>
Parse schema from a TOML string.
Sourcepub fn entity_labels(&self) -> Vec<&str>
pub fn entity_labels(&self) -> Vec<&str>
Entity label strings for GLiNER input.
Returns the type key names (e.g. “Person”, “Database”). Suitable for models trained on those label conventions.
Sourcepub fn entity_label_descriptions(&self) -> Vec<(&str, &str)>
pub fn entity_label_descriptions(&self) -> Vec<(&str, &str)>
Entity descriptions for zero-shot GLiNER inference.
Returns (description, key) pairs. Passing the description as the label
to GLiNER improves zero-shot recall because the model uses the label text
as a natural-language prompt. The key is the canonical type name used in
ExtractionSchema and benchmark fixtures.
Sourcepub fn entity_type_from_label<'a>(&'a self, label: &str) -> Option<&'a str>
pub fn entity_type_from_label<'a>(&'a self, label: &str) -> Option<&'a str>
Map a GLiNER class string back to the canonical entity type key.
When descriptions are used as labels, GLiNER returns the description as the span class. This method reverses that lookup.
Sourcepub fn relation_labels(&self) -> Vec<&str>
pub fn relation_labels(&self) -> Vec<&str>
Relation label strings for GLiREL/relation extraction input.
Trait Implementations§
Source§impl Clone for ExtractionSchema
impl Clone for ExtractionSchema
Source§fn clone(&self) -> ExtractionSchema
fn clone(&self) -> ExtractionSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExtractionSchema
impl Debug for ExtractionSchema
Source§impl Default for ExtractionSchema
impl Default for ExtractionSchema
Source§impl<'de> Deserialize<'de> for ExtractionSchema
impl<'de> Deserialize<'de> for ExtractionSchema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ExtractionSchema
impl RefUnwindSafe for ExtractionSchema
impl Send for ExtractionSchema
impl Sync for ExtractionSchema
impl Unpin for ExtractionSchema
impl UnsafeUnpin for ExtractionSchema
impl UnwindSafe for ExtractionSchema
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().