semantica.ontology provides the full lifecycle for knowledge graph schemas:
- Auto-generate ontologies from KG data via a 5-stage pipeline (Semantic Network → YAML → Types → Hierarchy → TTL)
- LLM-powered ontology generation for complex domains via
LLMOntologyGenerator - SHACL validation: generate shapes, validate graphs, and get violation reports
- OWL/RDF export in Turtle, RDF/XML, and JSON-LD formats
- Ontology Hub visual editor available in
semantica.explorer(v0.5.0)
Exported Classes
Getting Started
OntologyEngine is your main entry point for the complete ontology workflow:
OntologyEngine (Unified Facade)
OntologyEngine orchestrates the full ontology lifecycle: generation, validation, export, and evaluation:
OntologyEngine Methods
Ontology Quality Gate
Use the quality gate before export or deployment to catch structural issues without adding a runtime dependency:Thresholds
min_coverage (default 0.0) sets the minimum required coverage score, the average of class and property coverage from 0.0 to 1.0; the gate fails below it. max_errors (default 0.0) caps how many error/critical issues are allowed before the gate fails. max_warnings (default None) caps warning issues the same way, and None means warnings alone never fail the gate. fail_on_warnings is a separate parameter, not a thresholds key, passed to OntologyQualityGate(...) or .check(...) directly; when True, a single warning fails the gate regardless of max_warnings.
OntologyGenerator (5-Stage Pipeline)
OntologyGenerator auto-generates a formal ontology from your knowledge graph entities and relationships:
1
Semantic Network Parsing
Extract concepts and patterns from entity types and relationship structures in the source data.
2
YAML-to-Definition
Transform the extracted patterns into intermediate class and property definitions.
3
Definition-to-Types
Map definitions to OWL constructs:
owl:Class, owl:ObjectProperty, owl:DatatypeProperty.4
Hierarchy Generation
Build taxonomy trees using transitive closure and cycle detection: produces
rdfs:subClassOf chains.5
TTL Generation
Serialize the final ontology to Turtle format using
rdflib. Also available: RDF/XML and JSON-LD.SHACL Validation
Generate SHACL shapes from an ontology and validate any graph against them:Validation Report Fields
LLM-Powered Ontology Generation
For complex or novel domains where schema patterns are hard to infer statistically:OWL / RDF Export
Namespace Management
Ontology Evaluation
Measure coverage, completeness, and granularity of a generated ontology:Common Workflows
- Quick Start
- LLM-Powered Generation
- Export and Integration
Generate and validate an ontology in 3 steps:
Ingest an Existing Ontology
Load and parse an ontology file for downstream use:Ontology versioning (
VersionManager, OntologyVersion) has moved to semantica.change_management. Import from there: from semantica.change_management import VersionManager.- Reasoning — Apply inference rules over ontology axioms.
- Knowledge Graph — The graph being modeled by the ontology.
- Export — Export ontologies as RDF, OWL, or JSON-LD.
- Conflicts — Detect ontology constraint violations.
