|
| 1 | +//! Proposed addition: Semantic enrichment for DnPath |
| 2 | +//! |
| 3 | +//! This can be added to crates/lance-graph-callcenter/src/dn_path.rs |
| 4 | +//! or as a separate module. It is fully backward compatible. |
| 5 | +
|
| 6 | +use lance_graph_contract::ontology::Label; |
| 7 | + |
| 8 | +/// Semantic context that can be attached to a DnPath without changing its compact form. |
| 9 | +#[derive(Clone, Debug, Default)] |
| 10 | +pub struct SemanticContext { |
| 11 | + /// OGIT schema labels |
| 12 | + pub ogit_labels: Vec<Label>, |
| 13 | + |
| 14 | + /// OWL class or DOLCE category (e.g. "Endurant", "Perdurant", "Quality", "Role") |
| 15 | + pub owl_dolce_category: Option<String>, |
| 16 | + |
| 17 | + /// Optional references to CAM codebook centroids (for hybrid retrieval) |
| 18 | + pub cam_centroid_refs: Vec<u8>, |
| 19 | +} |
| 20 | + |
| 21 | +/// Extended version of DnPath that carries semantic information. |
| 22 | +#[derive(Clone, Debug)] |
| 23 | +pub struct DnPathWithSemantics { |
| 24 | + pub path: super::DnPath, |
| 25 | + pub semantic: SemanticContext, |
| 26 | +} |
| 27 | + |
| 28 | +impl DnPathWithSemantics { |
| 29 | + pub fn new(path: super::DnPath) -> Self { |
| 30 | + Self { |
| 31 | + path, |
| 32 | + semantic: SemanticContext::default(), |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + pub fn with_ogit_labels(mut self, labels: Vec<Label>) -> Self { |
| 37 | + self.semantic.ogit_labels = labels; |
| 38 | + self |
| 39 | + } |
| 40 | + |
| 41 | + pub fn with_owl_dolce_category(mut self, category: impl Into<String>) -> Self { |
| 42 | + self.semantic.owl_dolce_category = Some(category.into()); |
| 43 | + self |
| 44 | + } |
| 45 | + |
| 46 | + pub fn with_cam_centroids(mut self, centroids: Vec<u8>) -> Self { |
| 47 | + self.semantic.cam_centroid_refs = centroids; |
| 48 | + self |
| 49 | + } |
| 50 | + |
| 51 | + /// Convenience accessor for the original compact scent |
| 52 | + pub fn scent(&self) -> u8 { |
| 53 | + self.path.scent() |
| 54 | + } |
| 55 | +} |
0 commit comments