1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! # ggen-ontology-core - Ontology Handling Layer
//!
//! Core ontology processing module for ggen providing:
//! - RDF/Turtle (TTL) file loading and validation
//! - SPARQL query execution with deterministic results
//! - Entity mapping from domain models to standard ontology classes
//! - Comprehensive error handling with context
//!
//! ## Features
//! - **default**, **oxigraph**: Enables Oxigraph RDF store integration
//! - **sparql**: Enables SPARQL query support
//!
//! ## Architecture
//!
//! The ontology core is built with type-first design:
//! - All operations return `Result<T, OntologyError>` for explicit error handling
//! - Triple store operations are deterministic (same input → same output)
//! - Entity mapper provides confidence-scored ontology matches
//! - SPARQL generators produce consistent query strings
//!
//! ## Module Organization
//!
//! - `errors` - Error types with rich context
//! - `triple_store` - RDF/TTL loading and querying via Oxigraph
//! - `sparql_generator` - Deterministic SPARQL query building
//! - `entity_mapper` - Domain-to-ontology entity mapping
//! - `validators` - Syntax and semantic validation
//!
//! ## Examples
//!
//! ### Load and Query Ontology
//!
//! ```rust,no_run
//! use crate::ontology_core::triple_store::TripleStore;
//! use crate::ontology_core::sparql_generator::SparqlGenerator;
//!
//! // Create a new triple store
//! let store = TripleStore::new()?;
//!
//! // Load Turtle file
//! store.load_turtle("ontology.ttl")?;
//!
//! // Execute deterministic SPARQL query
//! let query = SparqlGenerator::find_policies_by_jurisdiction("US");
//! let results = store.query_sparql(&query)?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ### Map Entities to Ontology
//!
//! ```rust,no_run
//! use crate::ontology_core::entity_mapper::EntityMapper;
//!
//! // Map policy to ontology class with confidence score
//! let matches = EntityMapper::match_policy("Privacy Policy")?;
//! for m in matches {
//! println!("{}: {} (confidence: {})", m.label, m.class, m.score);
//! }
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ### Validate Ontology Files
//!
//! ```rust,no_run
//! use crate::ontology_core::validators::validate_turtle;
//!
//! let report = validate_turtle("ontology.ttl")?;
//! if report.is_valid {
//! println!("Ontology is valid");
//! }
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
// Public API re-exports
pub use ;
pub use ;
pub use SparqlGenerator;
pub use ;
pub use ;
/// Library version
pub const VERSION: &str = env!;