pub struct SemanticProcessor {
pub graph: HashMap<String, CognitiveNode>,
pub edges: Vec<CognitiveEdge>,
pub graft_history: Vec<GraftResult>,
}Expand description
Processes semantic fragments for extraction, grafting, and conflict detection.
Fields§
§graph: HashMap<String, CognitiveNode>The local cognitive graph (node_id -> CognitiveNode)
edges: Vec<CognitiveEdge>Edges in the local graph
graft_history: Vec<GraftResult>History of graft operations
Implementations§
Source§impl SemanticProcessor
impl SemanticProcessor
pub fn new() -> Self
Sourcepub fn add_node(&mut self, node: CognitiveNode)
pub fn add_node(&mut self, node: CognitiveNode)
Add a node to the local cognitive graph.
Sourcepub fn add_edge(&mut self, edge: CognitiveEdge)
pub fn add_edge(&mut self, edge: CognitiveEdge)
Add an edge to the local cognitive graph.
Sourcepub fn extract_fragment(
&self,
focus_nodes: &[String],
context_depth: usize,
perspective: &str,
) -> SemanticFragment
pub fn extract_fragment( &self, focus_nodes: &[String], context_depth: usize, perspective: &str, ) -> SemanticFragment
Extract a semantic fragment from the local graph around a set of focus nodes.
Traverses from each focus node up to context_depth hops,
collecting all reachable nodes and edges.
Sourcepub fn graft_fragment(&mut self, fragment: &SemanticFragment) -> GraftResult
pub fn graft_fragment(&mut self, fragment: &SemanticFragment) -> GraftResult
Graft a received semantic fragment onto the local cognitive graph.
Merges nodes and edges, detecting conflicts where existing nodes have different label than incoming ones.
Sourcepub fn detect_conflicts(
&self,
fragment: &SemanticFragment,
) -> Vec<ConflictDetail>
pub fn detect_conflicts( &self, fragment: &SemanticFragment, ) -> Vec<ConflictDetail>
Detect conflicts between local graph and an incoming fragment without actually grafting.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes in the local graph.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the number of edges in the local graph.
Sourcepub fn get_node(&self, id: &str) -> Option<&CognitiveNode>
pub fn get_node(&self, id: &str) -> Option<&CognitiveNode>
Get a node by ID.
Sourcepub fn conflict_history(&self) -> Vec<&[SemanticConflict]>
pub fn conflict_history(&self) -> Vec<&[SemanticConflict]>
Get all conflict history from grafts.