Ontologies in ABI
What are Ontologies?
Ontologies in ABI provide a formal representation of knowledge using semantic web technologies. They define:
- Classes/Concepts: Categories of entities (e.g., Person, Organization, Event)
- Properties: Relationships between entities or attributes of entities
- Individuals: Specific instances of classes
- Rules/Axioms: Logical constraints that govern relationships
ABI uses RDF (Resource Description Framework) and OWL (Web Ontology Language) to represent ontologies in a machine-readable format.
Ontology Organization
Ontologies in ABI are organized in a layered approach:
- Foundation or Top-Level Ontologies: Basic concepts like space, time, and objects (e.g., BFO - Basic Formal Ontology)
- Mid-Level Ontologies: Concepts common across domains (e.g., Common Core Ontologies)
- Domain Ontologies: Concepts specific to particular domains (e.g., Finance, Healthcare)
- Application Ontologies: Concepts specific to applications
The src/core/modules/ontology/ontologies/
directory contains the vetted ontologies used across ABI.
Creating Module Ontologies
When building a module, you can:
- Reuse existing ontologies: Leverage foundation and mid-level ontologies
- Extend with domain concepts: Add domain-specific classes and properties
- Create application ontologies: Define concepts specific to your module
File Structure
Ontologies can be placed in your module's directory:
src/custom/modules/your_module_name/
└── ontologies/
├── YourDomainOntology.ttl # Domain-level ontology
└── YourApplicationOntology.ttl # Application-specific ontology
Automatic Loading of Ontologies
Ontologies placed in your module's ontologies/
directory are automatically loaded when ABI starts up. The system:
- Reads all module definitions
- For each module, loads all ontology files listed in the module's
ontologies
list attribute - Adds them to the triple store using
services.triple_store_service.load_schema()
Schema Management
When a turtle file is loaded:
-
First-time Loading:
- The entire file is parsed and added to the triple store
- A schema record is created with metadata including file path, content hash, and timestamp
- The content is stored in base64 format for future comparisons
-
Updating Existing Files:
- When ABI starts, it checks the hash of each ontology file
- If unchanged, the file is skipped
- If changed, it:
- Compares the old and new versions to determine additions and deletions
- Adds only the new triples and removes only the deleted ones
- Updates the stored hash, timestamp, and content
This incremental update approach ensures that only the necessary changes are applied to the triple store, making the system more efficient when handling large ontologies.