Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

refactor: standardize triple_store module with comprehensive documentation

KaifAhmad1eeae93b1ed51
diff --git a/semantica/triple_store/__init__.py b/semantica/triple_store/__init__.py
index d05947d0..95399524 100644
--- a/semantica/triple_store/__init__.py
+++ b/semantica/triple_store/__init__.py
@@ -1,17 +1,43 @@
"""
-Triple store module for Semantica framework.
+Triple Store Module
-This module provides triple store integration and management
-for RDF data storage and querying.
+This module provides comprehensive triple store integration and management
+for RDF data storage and querying, supporting multiple triple store backends
+with unified interfaces.
-Exports:
- - TripleManager: Triple store management and CRUD operations
- - BlazegraphAdapter: Blazegraph integration
- - JenaAdapter: Apache Jena integration
- - RDF4JAdapter: Eclipse RDF4J integration
- - VirtuosoAdapter: Virtuoso RDF store integration
+Key Features:
+ - Multi-backend support (Blazegraph, Jena, RDF4J, Virtuoso)
+ - CRUD operations for RDF triples
+ - SPARQL query execution and optimization
+ - Bulk data loading with progress tracking
+ - Query caching and optimization
+ - Transaction support
+ - Store adapter pattern
+
+Main Classes:
+ - TripleManager: Main triple store management coordinator
- QueryEngine: SPARQL query execution and optimization
- BulkLoader: High-volume data loading
+ - BlazegraphAdapter: Blazegraph integration adapter
+ - JenaAdapter: Apache Jena integration adapter
+ - RDF4JAdapter: Eclipse RDF4J integration adapter
+ - VirtuosoAdapter: Virtuoso RDF store integration adapter
+ - TripleStore: Triple store configuration dataclass
+ - QueryResult: Query result representation dataclass
+ - QueryPlan: Query execution plan dataclass
+ - LoadProgress: Bulk loading progress dataclass
+
+Example Usage:
+ >>> from semantica.triple_store import TripleManager
+ >>> manager = TripleManager()
+ >>> store = manager.register_store("main", "blazegraph", "http://localhost:9999/blazegraph")
+ >>> result = manager.add_triple(triple, store_id="main")
+ >>> from semantica.triple_store import QueryEngine
+ >>> engine = QueryEngine()
+ >>> query_result = engine.execute_query(sparql_query, store_adapter)
+
+Author: Semantica Contributors
+License: MIT
"""
from .triple_manager import (
diff --git a/semantica/triple_store/blazegraph_adapter.py b/semantica/triple_store/blazegraph_adapter.py
index c881c89f..a47dcbb1 100644
--- a/semantica/triple_store/blazegraph_adapter.py
+++ b/semantica/triple_store/blazegraph_adapter.py
@@ -1,8 +1,30 @@
"""
-Blazegraph adapter for Semantica framework.
+Blazegraph Adapter Module
-This module provides Blazegraph integration for RDF storage
-and SPARQL querying.
+This module provides Blazegraph integration for RDF storage and SPARQL
+querying, enabling connection to Blazegraph instances with namespace
+management and bulk loading capabilities.
+
+Key Features:
+ - Blazegraph connection and authentication
+ - SPARQL query execution
+ - Bulk data loading and management
+ - Namespace and graph management
+ - REST API integration
+ - Performance optimization
+
+Main Classes:
+ - BlazegraphAdapter: Main Blazegraph integration adapter
+
+Example Usage:
+ >>> from semantica.triple_store import BlazegraphAdapter
+ >>> adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph", namespace="kb")
+ >>> result = adapter.execute_sparql(sparql_query)
+ >>> load_result = adapter.bulk_load(triples)
+ >>> namespace_result = adapter.create_namespace("new_namespace")
+
+Author: Semantica Contributors
+License: MIT
"""
from typing import Any, Dict, List, Optional
diff --git a/semantica/triple_store/bulk_loader.py b/semantica/triple_store/bulk_loader.py
index 99a4b339..8cd099d9 100644
--- a/semantica/triple_store/bulk_loader.py
+++ b/semantica/triple_store/bulk_loader.py
@@ -1,8 +1,31 @@
"""
-Bulk loader for Semantica framework.
+Bulk Loader Module
-This module provides high-volume data loading capabilities
-for triple stores.
+This module provides high-volume data loading capabilities for triple stores,
+enabling efficient batch processing with progress tracking and error recovery.
+
+Key Features:
+ - High-volume data loading strategies
+ - Batch processing and chunking
+ - Progress monitoring and reporting
+ - Error handling and recovery with retries
+ - Performance optimization
+ - Memory management for large datasets
+ - Stream-based loading
+
+Main Classes:
+ - BulkLoader: Main bulk loading coordinator
+ - LoadProgress: Bulk loading progress representation dataclass
+
+Example Usage:
+ >>> from semantica.triple_store import BulkLoader
+ >>> loader = BulkLoader(batch_size=1000, max_retries=3)
+ >>> progress = loader.load_triples(triples, store_adapter)
+ >>> print(f"Loaded {progress.loaded_triples}/{progress.total_triples} triples")
+ >>> validation = loader.validate_before_load(triples)
+
+Author: Semantica Contributors
+License: MIT
"""
from typing import Any, Dict, List, Optional
diff --git a/semantica/triple_store/jena_adapter.py b/semantica/triple_store/jena_adapter.py
index f66809fe..b5c82430 100644
--- a/semantica/triple_store/jena_adapter.py
+++ b/semantica/triple_store/jena_adapter.py
@@ -1,8 +1,29 @@
"""
-Apache Jena adapter for Semantica framework.
+Apache Jena Adapter Module
-This module provides Apache Jena integration for RDF storage
-and SPARQL querying.
+This module provides Apache Jena integration for RDF storage and SPARQL
+querying, supporting both in-memory and remote Fuseki endpoints.
+
+Key Features:
+ - Jena connection and configuration
+ - SPARQL query execution
+ - Model and dataset management
+ - Inference and reasoning support
+ - RDF serialization
+ - rdflib integration with fallback
+
+Main Classes:
+ - JenaAdapter: Main Jena integration adapter
+
+Example Usage:
+ >>> from semantica.triple_store import JenaAdapter
+ >>> adapter = JenaAdapter(endpoint="http://localhost:3030/ds", dataset="default")
+ >>> result = adapter.add_triples(triples)
+ >>> query_result = adapter.execute_sparql(sparql_query)
+ >>> rdf_turtle = adapter.serialize(format="turtle")
+
+Author: Semantica Contributors
+License: MIT
"""
from typing import Any, Dict, List, Optional
diff --git a/semantica/triple_store/query_engine.py b/semantica/triple_store/query_engine.py
index a0af3168..f37392f0 100644
--- a/semantica/triple_store/query_engine.py
+++ b/semantica/triple_store/query_engine.py
@@ -1,8 +1,33 @@
"""
-Query engine for Semantica framework.
+Query Engine Module
-This module provides SPARQL query execution and optimization
-for triple store operations.
+This module provides comprehensive SPARQL query execution and optimization
+for triple store operations, including query planning, caching, and performance
+monitoring.
+
+Key Features:
+ - SPARQL query execution and optimization
+ - Query planning and caching
+ - Result processing and formatting
+ - Performance monitoring and profiling
+ - Query validation
+ - Multi-store query support
+ - Query history tracking
+
+Main Classes:
+ - QueryEngine: Main query execution and optimization coordinator
+ - QueryResult: SPARQL query result representation dataclass
+ - QueryPlan: Query execution plan representation dataclass
+
+Example Usage:
+ >>> from semantica.triple_store import QueryEngine
+ >>> engine = QueryEngine(enable_caching=True, enable_optimization=True)
+ >>> result = engine.execute_query(sparql_query, store_adapter)
+ >>> plan = engine.plan_query(sparql_query)
+ >>> stats = engine.get_query_statistics()
+
+Author: Semantica Contributors
+License: MIT
"""
from typing import Any, Dict, List, Optional
diff --git a/semantica/triple_store/rdf4j_adapter.py b/semantica/triple_store/rdf4j_adapter.py
index e6e1e4db..8bb26fb6 100644
--- a/semantica/triple_store/rdf4j_adapter.py
+++ b/semantica/triple_store/rdf4j_adapter.py
@@ -1,8 +1,29 @@
"""
-RDF4J adapter for Semantica framework.
+RDF4J Adapter Module
-This module provides RDF4J integration for RDF storage
-and SPARQL querying.
+This module provides Eclipse RDF4J integration for RDF storage and SPARQL
+querying, supporting repository management and transaction operations.
+
+Key Features:
+ - RDF4J connection and repository management
+ - SPARQL query execution
+ - Repository configuration and setup
+ - Transaction support
+ - REST API integration
+ - Bulk operations
+
+Main Classes:
+ - RDF4JAdapter: Main RDF4J integration adapter
+
+Example Usage:
+ >>> from semantica.triple_store import RDF4JAdapter
+ >>> adapter = RDF4JAdapter(endpoint="http://localhost:8080/rdf4j-server", repository_id="repo1")
+ >>> result = adapter.execute_sparql(sparql_query)
+ >>> tx_id = adapter.begin_transaction()
+ >>> result = adapter.add_triples(triples)
+
+Author: Semantica Contributors
+License: MIT
"""
from typing import Any, Dict, List, Optional
diff --git a/semantica/triple_store/triple_manager.py b/semantica/triple_store/triple_manager.py
index 6de99d90..c2918f29 100644
--- a/semantica/triple_store/triple_manager.py
+++ b/semantica/triple_store/triple_manager.py
@@ -1,8 +1,32 @@
"""
-Triple manager for Semantica framework.
+Triple Manager Module
-This module provides CRUD operations for RDF triples
-and triple store management.
+This module provides comprehensive CRUD operations for RDF triples and triple
+store management, enabling unified access to multiple triple store backends
+through a common interface.
+
+Key Features:
+ - CRUD operations for RDF triples
+ - Multi-store management and registration
+ - Batch operations and bulk loading
+ - Triple validation and consistency
+ - Store adapter pattern
+ - Error handling and recovery
+
+Main Classes:
+ - TripleManager: Main triple store management coordinator
+ - TripleStore: Triple store configuration dataclass
+
+Example Usage:
+ >>> from semantica.triple_store import TripleManager
+ >>> manager = TripleManager()
+ >>> store = manager.register_store("main", "blazegraph", "http://localhost:9999/blazegraph")
+ >>> result = manager.add_triple(triple, store_id="main")
+ >>> triples = manager.get_triple(subject="http://example.org/entity1")
+ >>> result = manager.add_triples(triple_list, store_id="main", batch_size=1000)
+
+Author: Semantica Contributors
+License: MIT
"""
from typing import Any, Dict, List, Optional
diff --git a/semantica/triple_store/virtuoso_adapter.py b/semantica/triple_store/virtuoso_adapter.py
index e0db523e..bb8358bc 100644
--- a/semantica/triple_store/virtuoso_adapter.py
+++ b/semantica/triple_store/virtuoso_adapter.py
@@ -1,8 +1,29 @@
"""
-Virtuoso adapter for Semantica framework.
+Virtuoso Adapter Module
-This module provides Virtuoso integration for RDF storage
-and SPARQL querying.
+This module provides Virtuoso RDF store integration for RDF storage and
+SPARQL querying, supporting cluster connections and query optimization.
+
+Key Features:
+ - Virtuoso connection and authentication
+ - SPARQL query execution
+ - Bulk data loading and management
+ - Graph and namespace management
+ - Cluster connection support
+ - Query optimization
+
+Main Classes:
+ - VirtuosoAdapter: Main Virtuoso integration adapter
+
+Example Usage:
+ >>> from semantica.triple_store import VirtuosoAdapter
+ >>> adapter = VirtuosoAdapter(endpoint="http://localhost:8890/sparql", username="dba", password="dba")
+ >>> result = adapter.execute_sparql(sparql_query)
+ >>> load_result = adapter.bulk_load(triples, graph="http://example.org/graph")
+ >>> cluster_status = adapter.connect_cluster(cluster_config)
+
+Author: Semantica Contributors
+License: MIT
"""
from typing import Any, Dict, List, Optional