diff --git a/cookbook/advanced/Advanced_Vector_Store_and_Search.ipynb b/cookbook/advanced/Advanced_Vector_Store_and_Search.ipynb
index 10822733..33630060 100644
--- a/cookbook/advanced/Advanced_Vector_Store_and_Search.ipynb
+++ b/cookbook/advanced/Advanced_Vector_Store_and_Search.ipynb
@@ -79,14 +79,14 @@
"metadata": {},
"outputs": [],
"source": [
- "from semantica.vector_store import FAISSAdapter\n",
+ "from semantica.vector_store import FAISSStore\n",
"import numpy as np\n",
"\n",
"# Create some example vectors (like document embeddings)\n",
"vectors = np.random.rand(5000, 768).astype('float32')\n",
"query = np.random.rand(768).astype('float32')\n",
"\n",
- "adapter = FAISSAdapter(dimension=768)\n",
+ "adapter = FAISSStore(dimension=768)\n",
"\n",
"# HNSW Index - Best for most cases\n",
"index = adapter.create_index(index_type=\"hnsw\", metric=\"L2\", m=16)\n",
diff --git a/cookbook/introduction/09_Graph_Store.ipynb b/cookbook/introduction/09_Graph_Store.ipynb
index c8b7c666..b0210251 100644
--- a/cookbook/introduction/09_Graph_Store.ipynb
+++ b/cookbook/introduction/09_Graph_Store.ipynb
@@ -363,7 +363,7 @@
{
"data": {
"text/html": [
- "
🧠 Semantica - 📊 Current Progress
| Status | Action | Module | Submodule | File | Time |
|---|
| ✅ | Semantica is processing | ⏳ graph_store | Neo4jAdapter | - | 0.14s |
"
+ "🧠 Semantica - 📊 Current Progress
| Status | Action | Module | Submodule | File | Time |
|---|
| ✅ | Semantica is processing | ⏳ graph_store | Neo4jStore | - | 0.14s |
"
],
"text/plain": [
""
diff --git a/cookbook/introduction/10_Graph_Analytics.ipynb b/cookbook/introduction/10_Graph_Analytics.ipynb
index 2cb7ef7e..360912cb 100644
--- a/cookbook/introduction/10_Graph_Analytics.ipynb
+++ b/cookbook/introduction/10_Graph_Analytics.ipynb
@@ -259,18 +259,18 @@
}
],
"source": [
- "!pip install semantica\n"
+ "!pip install semantica"
]
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "🧠 Semantica - 📊 Current Progress
| Status | Action | Module | Submodule | File | Time |
|---|
| ✅ | Semantica is building | 🧠 kg | GraphBuilder | - | 0.07s |
| 🔄 | Semantica is building | 🧠 kg | EntityResolver | - | 381.06s |
| ✅ | Semantica is deduplicating | 🔄 deduplication | DuplicateDetector | - | 0.05s |
| ✅ | Semantica is deduplicating | 🔄 deduplication | SimilarityCalculator | - | 0.01s |
| ✅ | Semantica is building | 🧠 kg | CentralityCalculator | - | 0.00s |
| ✅ | Semantica is building | 🧠 kg | CommunityDetector | - | 0.00s |
"
+ "🧠 Semantica - 📊 Current Progress
| Status | Action | Module | Submodule | File | Time |
|---|
| ✅ | Semantica is building | 🧠 kg | GraphBuilder | - | 0.08s |
| 🔄 | Semantica is building | 🧠 kg | EntityResolver | - | 131.06s |
| ✅ | Semantica is deduplicating | 🔄 deduplication | DuplicateDetector | - | 0.04s |
| ✅ | Semantica is deduplicating | 🔄 deduplication | SimilarityCalculator | - | 0.01s |
| ✅ | Semantica is resolving | ⚠️ conflicts | ConflictDetector | - | 0.00s |
| ✅ | Semantica is building | 🧠 kg | CentralityCalculator | - | 0.00s |
| ✅ | Semantica is building | 🧠 kg | CommunityDetector | - | 0.01s |
"
],
"text/plain": [
""
@@ -329,7 +329,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -367,25 +367,15 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Detected 4 communities\n"
- ]
- },
- {
- "ename": "TypeError",
- "evalue": "unhashable type: 'slice'",
- "output_type": "error",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
- "Cell \u001b[1;32mIn[8], line 8\u001b[0m\n\u001b[0;32m 5\u001b[0m communities \u001b[38;5;241m=\u001b[39m community_detector\u001b[38;5;241m.\u001b[39mdetect_communities(kg)\n\u001b[0;32m 7\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDetected \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(communities)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m communities\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m----> 8\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, community \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(\u001b[43mcommunities\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m]\u001b[49m, \u001b[38;5;241m1\u001b[39m):\n\u001b[0;32m 9\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m Community \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mi\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(community)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m entities\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
- "\u001b[1;31mTypeError\u001b[0m: unhashable type: 'slice'"
+ "Detected 1 communities\n",
+ " Community 1: 3 entities\n"
]
}
],
@@ -394,11 +384,15 @@
"\n",
"community_detector = CommunityDetector()\n",
"\n",
- "communities = community_detector.detect_communities(kg)\n",
+ "# Get detection result\n",
+ "result = community_detector.detect_communities(kg)\n",
+ "\n",
+ "# Extract communities list from result dictionary\n",
+ "communities = result.get(\"communities\", [])\n",
"\n",
"print(f\"Detected {len(communities)} communities\")\n",
"for i, community in enumerate(communities[:3], 1):\n",
- " print(f\" Community {i}: {len(community)} entities\")\n"
+ " print(f\" Community {i}: {len(community)} entities\")"
]
},
{
diff --git a/cookbook/introduction/13_Vector_Store.ipynb b/cookbook/introduction/13_Vector_Store.ipynb
index 43ed0579..c0b6ad13 100644
--- a/cookbook/introduction/13_Vector_Store.ipynb
+++ b/cookbook/introduction/13_Vector_Store.ipynb
@@ -55,11 +55,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "WARNING: Ignoring invalid distribution ~gno (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~lotly (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~ython-socketio (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~gno (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~lotly (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~ython-socketio (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~gno (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~lotly (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n",
+ "WARNING: Ignoring invalid distribution ~ython-socketio (C:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages)\n"
+ ]
+ }
+ ],
"source": [
- "!pip install semantica\n"
+ "!pip install -q semantica\n"
]
},
{
@@ -81,9 +97,30 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "🧠 Semantica - 📊 Current Progress
| Status | Action | Module | Submodule | File | Time |
|---|
| ❌ | Semantica is indexing | 📊 vector_store | VectorStore | - | 0.01s |
| ✅ | Semantica is indexing | 📊 vector_store | FAISSAdapter | - | 0.27s |
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Stored 100 vectors\n",
+ "First 3 IDs: ['vec_0', 'vec_2', 'vec_4']\n"
+ ]
+ }
+ ],
"source": [
"from semantica.vector_store import VectorStore\n",
"from semantica.embeddings import TextEmbedder\n",
@@ -105,7 +142,6 @@
" {\"text\": txt, \"category\": \"science\" if i % 2 == 0 else \"technology\", \"year\": 2020 + (i % 4)}\n",
" for i, txt in enumerate(texts)\n",
"]\n",
- "\n",
"# 4. Store vectors\n",
"vector_ids = store.store_vectors(vectors, metadata=metadata)\n",
"\n",
@@ -130,21 +166,41 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "TypeError",
+ "evalue": "FAISSAdapter.add_vectors() got multiple values for argument 'ids'",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[1;32mIn[4], line 12\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[38;5;66;03m# Add vectors to index\u001b[39;00m\n\u001b[0;32m 11\u001b[0m vectors_array \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marray(vectors)\u001b[38;5;241m.\u001b[39mastype(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfloat32\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m---> 12\u001b[0m \u001b[43madapter\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madd_vectors\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindex\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvectors_array\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvector_ids\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 14\u001b[0m \u001b[38;5;66;03m# Search using index\u001b[39;00m\n\u001b[0;32m 15\u001b[0m query_array \u001b[38;5;241m=\u001b[39m query_vector\u001b[38;5;241m.\u001b[39mastype(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfloat32\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
+ "\u001b[1;31mTypeError\u001b[0m: FAISSAdapter.add_vectors() got multiple values for argument 'ids'"
+ ]
+ }
+ ],
"source": [
- "# Create query vector\n",
- "query_vector = np.random.rand(768)\n",
+ "from semantica.vector_store import VectorIndexer, FAISSAdapter\n",
"\n",
- "# Search for similar vectors\n",
- "results = store.search_vectors(query_vector, k=10)\n",
+ "# Create indexer\n",
+ "indexer = VectorIndexer(backend=\"faiss\", dimension=dimension)\n",
"\n",
- "print(f\"Found {len(results)} similar vectors\")\n",
- "print(\"\\nTop 5 results:\")\n",
- "for i, result in enumerate(results[:5], 1):\n",
- " print(f\"{i}. ID: {result['id']}, Score: {result['score']:.3f}\")\n",
- " print(f\" Metadata: {result.get('metadata', {})}\")"
+ "# Create HNSW index for fast approximate search\n",
+ "adapter = FAISSAdapter(dimension=dimension)\n",
+ "index = adapter.create_index(index_type=\"hnsw\", metric=\"L2\", m=16)\n",
+ "\n",
+ "# Add vectors to index\n",
+ "vectors_array = np.array(vectors).astype('float32')\n",
+ "adapter.add_vectors(index, vectors_array, ids=vector_ids)\n",
+ "\n",
+ "# Search using index\n",
+ "query_array = query_vector.astype('float32')\n",
+ "distances, indices = adapter.search(index, query_array.reshape(1, -1), k=10)\n",
+ "\n",
+ "print(f\"Index search found {len(indices[0])} results\")\n",
+ "print(f\"Distances: {distances[0][:5]}\")"
]
},
{
@@ -165,29 +221,46 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "AssertionError",
+ "evalue": "",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[1;32mIn[7], line 19\u001b[0m\n\u001b[0;32m 17\u001b[0m \u001b[38;5;66;03m# Search using index\u001b[39;00m\n\u001b[0;32m 18\u001b[0m query_array \u001b[38;5;241m=\u001b[39m query_vector\u001b[38;5;241m.\u001b[39mastype(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfloat32\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m---> 19\u001b[0m distances, indices \u001b[38;5;241m=\u001b[39m \u001b[43mindex\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msearch\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquery_array\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreshape\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mk\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m10\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 21\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mIndex search found \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(indices[\u001b[38;5;241m0\u001b[39m])\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m results\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 22\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDistances: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdistances[\u001b[38;5;241m0\u001b[39m][:\u001b[38;5;241m5\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n",
+ "File \u001b[1;32m~\\semantica\\semantica\\vector_store\\faiss_adapter.py:80\u001b[0m, in \u001b[0;36mFAISSIndex.search\u001b[1;34m(self, query_vectors, k)\u001b[0m\n\u001b[0;32m 76\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21msearch\u001b[39m(\n\u001b[0;32m 77\u001b[0m \u001b[38;5;28mself\u001b[39m, query_vectors: np\u001b[38;5;241m.\u001b[39mndarray, k: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m\n\u001b[0;32m 78\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Tuple[np\u001b[38;5;241m.\u001b[39mndarray, np\u001b[38;5;241m.\u001b[39mndarray]:\n\u001b[0;32m 79\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Search for similar vectors.\"\"\"\u001b[39;00m\n\u001b[1;32m---> 80\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mindex\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msearch\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquery_vectors\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mastype\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfloat32\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mk\u001b[49m\u001b[43m)\u001b[49m\n",
+ "File \u001b[1;32mc:\\Users\\Mohd Kaif\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\faiss\\class_wrappers.py:329\u001b[0m, in \u001b[0;36mhandle_Index..replacement_search\u001b[1;34m(self, x, k, params, D, I)\u001b[0m\n\u001b[0;32m 327\u001b[0m n, d \u001b[38;5;241m=\u001b[39m x\u001b[38;5;241m.\u001b[39mshape\n\u001b[0;32m 328\u001b[0m x \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mascontiguousarray(x, dtype\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfloat32\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m--> 329\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m d \u001b[38;5;241m==\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39md\n\u001b[0;32m 331\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m k \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[0;32m 333\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m D \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
+ "\u001b[1;31mAssertionError\u001b[0m: "
+ ]
+ }
+ ],
"source": [
"from semantica.vector_store import VectorIndexer, FAISSAdapter\n",
"\n",
+ "# Get dimension from vectors to ensure consistency\n",
+ "dimension = len(vectors[0]) if len(vectors) > 0 else 384\n",
+ "\n",
"# Create indexer\n",
- "indexer = VectorIndexer(backend=\"faiss\", dimension=768)\n",
+ "indexer = VectorIndexer(backend=\"faiss\", dimension=dimension)\n",
"\n",
"# Create HNSW index for fast approximate search\n",
- "adapter = FAISSAdapter(dimension=768)\n",
+ "adapter = FAISSAdapter(dimension=dimension)\n",
"index = adapter.create_index(index_type=\"hnsw\", metric=\"L2\", m=16)\n",
"\n",
"# Add vectors to index\n",
"vectors_array = np.array(vectors).astype('float32')\n",
- "adapter.add_vectors(index, vectors_array, ids=vector_ids)\n",
+ "adapter.add_vectors(vectors_array, ids=vector_ids)\n",
"\n",
"# Search using index\n",
"query_array = query_vector.astype('float32')\n",
- "distances, indices = adapter.search(index, query_array, k=10)\n",
+ "distances, indices = index.search(query_array.reshape(1, -1), k=10)\n",
"\n",
- "print(f\"Index search found {len(indices)} results\")\n",
- "print(f\"Distances: {distances[:5]}\")"
+ "print(f\"Index search found {len(indices[0])} results\")\n",
+ "print(f\"Distances: {distances[0][:5]}\")"
]
},
{
@@ -575,9 +648,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.0"
+ "version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
-}
\ No newline at end of file
+}
diff --git a/cookbook/introduction/20_Triplet_Store.ipynb b/cookbook/introduction/20_Triplet_Store.ipynb
index 45feac8b..94a3d8e3 100644
--- a/cookbook/introduction/20_Triplet_Store.ipynb
+++ b/cookbook/introduction/20_Triplet_Store.ipynb
@@ -33,10 +33,10 @@
"| `TripletManager` | Store coordination | All triplet operations |\n",
"| `QueryEngine` | SPARQL execution | Query optimization |\n",
"| `BulkLoader` | High-volume loading | Large datasets |\n",
- "| `BlazegraphAdapter` | Blazegraph backend | High performance |\n",
- "| `JenaAdapter` | Jena backend | Java integration |\n",
- "| `RDF4JAdapter` | RDF4J backend | Transaction support |\n",
- "| `VirtuosoAdapter` | Virtuoso backend | Enterprise scale |\n",
+ "| `BlazegraphStore` | Blazegraph backend | High performance |\n",
+ "| `JenaStore` | Jena backend | Java integration |\n",
+ "| `RDF4JStore` | RDF4J backend | Transaction support |\n",
+ "| `VirtuosoStore` | Virtuoso backend | Enterprise scale |\n",
"\n",
"---\n",
"\n",
@@ -249,13 +249,13 @@
"metadata": {},
"outputs": [],
"source": [
- "from semantica.triplet_store import QueryEngine, BlazegraphAdapter\n",
+ "from semantica.triplet_store import QueryEngine, BlazegraphStore\n",
"\n",
"# Create query engine with caching\n",
"engine = QueryEngine(enable_caching=True, enable_optimization=True)\n",
"\n",
- "# Create adapter\n",
- "adapter = BlazegraphAdapter(endpoint=\"http://localhost:9999/blazegraph/sparql\")\n",
+ "# Create store\n",
+ "store = BlazegraphStore(endpoint=\"http://localhost:9999/blazegraph/sparql\")\n",
"\n",
"# SELECT query\n",
"select_query = \"\"\"\n",
@@ -270,7 +270,7 @@
"LIMIT 10\n",
"\"\"\"\n",
"\n",
- "result = engine.execute_query(select_query, adapter)\n",
+ "result = engine.execute_query(select_query, store)\n",
"\n",
"print(f\"Query Results:\")\n",
"print(f\" Variables: {result.variables}\")\n",
@@ -381,10 +381,10 @@
" f\"Batch {progress.current_batch}/{progress.total_batches}\")\n",
"\n",
"# Load triplets with progress tracking\n",
- "adapter = BlazegraphAdapter(endpoint=\"http://localhost:9999/blazegraph/sparql\")\n",
+ "store = BlazegraphStore(endpoint=\"http://localhost:9999/blazegraph/sparql\")\n",
"progress = loader.load_triplets(\n",
" large_dataset,\n",
- " adapter,\n",
+ " store,\n",
" progress_callback=progress_callback\n",
")\n",
"\n",
@@ -399,11 +399,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Step 7: Store Adapters\n",
+ "## Step 7: Store Backends\n",
"\n",
"Work with different triplet store backends.\n",
"\n",
- "### Blazegraph Adapter\n",
+ "### Blazegraph Store\n",
"\n",
"High-performance triplet store with GPU acceleration."
]
@@ -414,10 +414,10 @@
"metadata": {},
"outputs": [],
"source": [
- "from semantica.triplet_store import BlazegraphAdapter\n",
+ "from semantica.triplet_store import BlazegraphStore\n",
"\n",
- "# Create Blazegraph adapter\n",
- "blazegraph = BlazegraphAdapter(\n",
+ "# Create Blazegraph store\n",
+ "blazegraph = BlazegraphStore(\n",
" endpoint=\"http://localhost:9999/blazegraph/sparql\",\n",
" namespace=\"kb\",\n",
" timeout=30\n",
@@ -440,7 +440,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Jena Adapter\n",
+ "### Jena Store\n",
"\n",
"Full-featured RDF framework with inference support."
]
@@ -451,13 +451,13 @@
"metadata": {},
"outputs": [],
"source": [
- "from semantica.triplet_store import JenaAdapter\n",
+ "from semantica.triplet_store import JenaStore\n",
"\n",
- "# Create Jena adapter (in-memory)\n",
- "jena = JenaAdapter()\n",
+ "# Create Jena store (in-memory)\n",
+ "jena = JenaStore()\n",
"\n",
"# Or connect to Fuseki endpoint\n",
- "# jena = JenaAdapter(\n",
+ "# jena = JenaStore(\n",
"# endpoint=\"http://localhost:3030/ds\",\n",
"# dataset=\"default\",\n",
"# enable_inference=True\n",
@@ -495,7 +495,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### RDF4J Adapter\n",
+ "### RDF4J Store\n",
"\n",
"Java-based RDF framework with transaction support."
]
@@ -506,10 +506,10 @@
"metadata": {},
"outputs": [],
"source": [
- "from semantica.triplet_store import RDF4JAdapter\n",
+ "from semantica.triplet_store import RDF4JStore\n",
"\n",
"# Create RDF4J adapter\n",
- "rdf4j = RDF4JAdapter(\n",
+ "rdf4j = RDF4JStore(\n",
" server_url=\"http://localhost:8080/rdf4j-server\",\n",
" repository_id=\"test\"\n",
")\n",
@@ -538,7 +538,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Virtuoso Adapter\n",
+ "### Virtuoso Store\n",
"\n",
"Enterprise-grade RDF store with SQL integration."
]
@@ -549,10 +549,10 @@
"metadata": {},
"outputs": [],
"source": [
- "from semantica.triplet_store import VirtuosoAdapter\n",
+ "from semantica.triplet_store import VirtuosoStore\n",
"\n",
- "# Create Virtuoso adapter\n",
- "virtuoso = VirtuosoAdapter(\n",
+ "# Create Virtuoso store\n",
+ "virtuoso = VirtuosoStore(\n",
" host=\"localhost\",\n",
" port=1111,\n",
" user=\"dba\",\n",
diff --git a/docs/modules.md b/docs/modules.md
index af93f70b..bdd5e1c2 100644
--- a/docs/modules.md
+++ b/docs/modules.md
@@ -439,7 +439,7 @@ These modules handle persistence and retrieval of vectors, graphs, and triplets.
- `AudioEmbedder` — Generate audio embeddings
- `MultimodalEmbedder` — Combine multiple modalities
- `EmbeddingOptimizer` — Optimize embedding quality
-- `ProviderAdapters` — Support for OpenAI, Cohere, etc.
+- `ProviderStores` — Support for OpenAI, Cohere, etc.
**Quick Example:**
@@ -479,8 +479,8 @@ print(f"Similarity: {similarity:.3f}")
**Components:**
- `VectorStore` — Main vector store interface
-- `FAISSAdapter` — FAISS integration
-- `WeaviateAdapter` — Weaviate integration
+- `FAISSStore` — FAISS integration
+- `WeaviateStore` — Weaviate integration
- `HybridSearch` — Combine vector and keyword search
- `VectorRetriever` — Retrieve relevant vectors
@@ -523,8 +523,8 @@ results = hybrid_search.search(
**Components:**
- `GraphStore` — Main graph store interface
-- `Neo4jAdapter` — Neo4j database integration
-- `FalkorDBAdapter` — FalkorDB (Redis-based) integration
+- `Neo4jStore` — Neo4j database integration
+- `FalkorDBStore` — FalkorDB (Redis-based) integration
- `NodeManager` — Node CRUD operations
- `RelationshipManager` — Relationship CRUD operations
- `QueryEngine` — Cypher query execution
@@ -575,17 +575,17 @@ results = store.execute_query("MATCH (p:Person) RETURN p.name")
- Bulk data loading with progress tracking
- Query caching and optimization
- Transaction support
-- Store adapter pattern
+- Store backend pattern
**Components:**
- `TripletManager` — Main triplet store management coordinator
- `QueryEngine` — SPARQL query execution and optimization
- `BulkLoader` — High-volume data loading with progress tracking
-- `BlazegraphAdapter` — Blazegraph integration
-- `JenaAdapter` — Apache Jena integration
-- `RDF4JAdapter` — Eclipse RDF4J integration
-- `VirtuosoAdapter` — Virtuoso RDF store integration
+- `BlazegraphStore` — Blazegraph integration
+- `JenaStore` — Apache Jena integration
+- `RDF4JStore` — Eclipse RDF4J integration
+- `VirtuosoStore` — Virtuoso RDF store integration
- `QueryPlan` — Query execution plan dataclass
- `LoadProgress` — Bulk loading progress tracking
diff --git a/docs/reference/embeddings.md b/docs/reference/embeddings.md
index d9445de1..51268661 100644
--- a/docs/reference/embeddings.md
+++ b/docs/reference/embeddings.md
@@ -48,7 +48,7 @@ The **Embeddings Module** provides a unified interface for generating vector rep
## 🏗️ Architecture Components
### EmbeddingGenerator (The Orchestrator)
-The main entry point for generating embeddings. It manages the active model and routes requests to the appropriate provider adapter.
+The main entry point for generating embeddings. It manages the active model and routes requests to the appropriate provider store.
#### **Constructor Parameters**
* `method` (Default: `"fastembed"`): The embedding provider to use (e.g., `"sentence_transformers"`, `"openai"`, `"fastembed"`).
diff --git a/docs/reference/graph_store.md b/docs/reference/graph_store.md
index 5dae8f18..85e424a0 100644
--- a/docs/reference/graph_store.md
+++ b/docs/reference/graph_store.md
@@ -169,11 +169,11 @@ Graph analytics and algorithms.
- `degree_centrality(labels, rel_type, direction, **options)` - Calculate degree centrality
- `connected_components(labels, **options)` - Find connected components
-### Adapter Classes
+### Store Backends
-#### Neo4jAdapter
+#### Neo4jStore
-Enterprise-grade Neo4j backend adapter.
+Enterprise-grade Neo4j backend store.
**Features:**
- Bolt protocol support
@@ -188,9 +188,9 @@ Enterprise-grade Neo4j backend adapter.
- `Neo4jTransaction` - Transaction wrapper
-#### FalkorDBAdapter
+#### FalkorDBStore
-High-performance Redis-based FalkorDB backend adapter.
+High-performance Redis-based FalkorDB backend store.
**Features:**
- Sparse matrix representation
diff --git a/docs/reference/triplet_store.md b/docs/reference/triplet_store.md
index aa554a22..758ab6a6 100644
--- a/docs/reference/triplet_store.md
+++ b/docs/reference/triplet_store.md
@@ -318,9 +318,9 @@ progress = loader.load_from_string(
---
-### Backend Adapters
+### Store Backends
-#### BlazegraphAdapter
+#### BlazegraphStore
High-performance triplet store with GPU acceleration support.
@@ -334,24 +334,24 @@ High-performance triplet store with GPU acceleration support.
**Example:**
```python
-from semantica.triplet_store import BlazegraphAdapter
+from semantica.triplet_store import BlazegraphStore
-adapter = BlazegraphAdapter(
+store = BlazegraphStore(
endpoint="http://localhost:9999/blazegraph/sparql",
namespace="kb", # Blazegraph namespace
timeout=30
)
-adapter.connect()
+store.connect()
# Create namespace
-adapter.create_namespace("my_kb", properties={
+store.create_namespace("my_kb", properties={
"com.bigdata.rdf.store.AbstractTripleStore.textIndex": "true",
"com.bigdata.rdf.store.AbstractTripleStore.geoSpatial": "true"
})
# Add triplets
-adapter.add_triplet(
+store.add_triplet(
subject="http://example.org/Alice",
predicate="http://example.org/name",
object_literal="Alice",
@@ -359,7 +359,7 @@ adapter.add_triplet(
)
# Full-text search
-results = adapter.query("""
+results = store.query("""
PREFIX bds:
SELECT ?subject ?score WHERE {
?subject bds:search "machine learning" .
@@ -371,7 +371,7 @@ results = adapter.query("""
---
-#### JenaAdapter
+#### JenaStore
Full-featured RDF framework with TDB2 storage.
@@ -385,30 +385,30 @@ Full-featured RDF framework with TDB2 storage.
**Example:**
```python
-from semantica.triplet_store import JenaAdapter
+from semantica.triplet_store import JenaStore
-adapter = JenaAdapter(
+store = JenaStore(
tdb_directory="./tdb2_data",
inference="rdfs" # rdfs, owl, or None
)
-adapter.connect()
+store.connect()
# Add triplets with inference
-adapter.add_triplet(
+store.add_triplet(
subject="http://example.org/Dog",
predicate="http://www.w3.org/2000/01/rdf-schema#subClassOf",
object="http://example.org/Animal"
)
-adapter.add_triplet(
+store.add_triplet(
subject="http://example.org/Fido",
predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
object="http://example.org/Dog"
)
# Query with inference (Fido is inferred to be an Animal)
-results = adapter.query("""
+results = store.query("""
PREFIX rdf:
PREFIX ex:
@@ -431,13 +431,13 @@ ex:PersonShape a sh:NodeShape ;
] .
"""
-validation_report = adapter.validate_shacl(shapes)
+validation_report = store.validate_shacl(shapes)
print(f"Valid: {validation_report['conforms']}")
```
---
-#### RDF4JAdapter
+#### RDF4JStore
Java-based RDF framework with multiple storage backends.
@@ -451,29 +451,29 @@ Java-based RDF framework with multiple storage backends.
**Example:**
```python
-from semantica.triplet_store import RDF4JAdapter
+from semantica.triplet_store import RDF4JStore
-adapter = RDF4JAdapter(
+store = RDF4JStore(
server_url="http://localhost:8080/rdf4j-server",
repository_id="my_repo"
)
-adapter.connect()
+store.connect()
# Add triplet with transaction
-adapter.begin_transaction()
+store.begin_transaction()
try:
- adapter.add_triplet(
+ store.add_triplet(
subject="http://example.org/Alice",
predicate="http://example.org/name",
object_literal="Alice"
)
- adapter.commit_transaction()
+ store.commit_transaction()
except Exception as e:
- adapter.rollback_transaction()
+ store.rollback_transaction()
# Query with reasoning
-results = adapter.query("""
+results = store.query("""
PREFIX ex:
SELECT ?person WHERE {
?person ex:name ?name .
@@ -483,7 +483,7 @@ results = adapter.query("""
---
-#### VirtuosoAdapter
+#### VirtuosoStore
Enterprise-grade RDF store with SQL integration.
@@ -497,21 +497,21 @@ Enterprise-grade RDF store with SQL integration.
**Example:**
```python
-from semantica.triplet_store import VirtuosoAdapter
+from semantica.triplet_store import VirtuosoStore
-adapter = VirtuosoAdapter(
+store = VirtuosoStore(
host="localhost",
port=1111,
user="dba",
password="dba"
)
-adapter.connect()
+store.connect()
# Add triplets to named graph
graph_uri = "http://example.org/graph1"
-adapter.add_triplet(
+store.add_triplet(
subject="http://example.org/Alice",
predicate="http://example.org/name",
object_literal="Alice",
@@ -519,7 +519,7 @@ adapter.add_triplet(
)
# Query specific graph
-results = adapter.query(f"""
+results = store.query(f"""
PREFIX ex:
SELECT ?person ?name
FROM <{graph_uri}>
@@ -897,11 +897,11 @@ progress = loader.load("large_dataset.nt", format="ntriples")
```python
# Create selective indexes
-adapter.create_index("predicate", ["http://example.org/name"])
-adapter.create_index("object", ["http://example.org/Person"])
+store.create_index("predicate", ["http://example.org/name"])
+store.create_index("object", ["http://example.org/Person"])
# Full-text index for specific predicates
-adapter.create_fulltext_index([
+store.create_fulltext_index([
"http://example.org/description",
"http://example.org/content"
])
@@ -979,7 +979,7 @@ results = semantic_search("machine learning", limit=5)
```python
# Solution 1: Add indexes
-adapter.create_index("predicate", ["http://example.org/knows"])
+store.create_index("predicate", ["http://example.org/knows"])
# Solution 2: Optimize query
# Bad: Cartesian product
diff --git a/docs/reference/vector_store.md b/docs/reference/vector_store.md
index 1309e99b..241ed80d 100644
--- a/docs/reference/vector_store.md
+++ b/docs/reference/vector_store.md
@@ -226,15 +226,15 @@ results = searcher.search(
)
```
-### Adapters
+### Store Backends
Backend-specific implementations:
-- `FAISSAdapter`: Local, in-memory/disk.
-- `WeaviateAdapter`: Schema-aware vector DB.
-- `QdrantAdapter`: Rust-based high-performance DB.
-- `MilvusAdapter`: Scalable cloud-native DB.
+- `FAISSStore`: Local, in-memory/disk.
+- `WeaviateStore`: Schema-aware vector DB.
+- `QdrantStore`: Rust-based high-performance DB.
+- `MilvusStore`: Scalable cloud-native DB.
-#### FAISSAdapter
+#### FAISSStore
Local vector storage with multiple index types.
@@ -246,10 +246,10 @@ Local vector storage with multiple index types.
**Example:**
```python
-from semantica.vector_store import FAISSAdapter, FAISSIndexBuilder
+from semantica.vector_store import FAISSStore, FAISSIndexBuilder
import numpy as np
-adapter = FAISSAdapter(dimension=768)
+store = FAISSStore(dimension=768)
# Create HNSW index
builder = FAISSIndexBuilder()
@@ -257,14 +257,14 @@ index = builder.build(index_type="hnsw", dimension=768, m=16)
# Add vectors
vectors = np.random.rand(1000, 768).astype('float32')
-adapter.add_vectors(index, vectors, ids=[f"vec_{i}" for i in range(1000)])
+store.add_vectors(vectors, ids=[f"vec_{i}" for i in range(1000)])
# Search
query = np.random.rand(768).astype('float32')
-distances, indices = adapter.search(index, query, k=10)
+distances, indices = store.search(index, query, k=10)
```
-#### WeaviateAdapter
+#### WeaviateStore
Schema-aware vector database with GraphQL.
@@ -276,25 +276,25 @@ Schema-aware vector database with GraphQL.
**Example:**
```python
-from semantica.vector_store import WeaviateAdapter
+from semantica.vector_store import WeaviateStore
-adapter = WeaviateAdapter(url="http://localhost:8080")
-adapter.connect()
+store = WeaviateStore(url="http://localhost:8080")
+store.connect()
# Create schema
-adapter.create_schema(
+store.create_schema(
"Document",
properties=[{"name": "text", "dataType": "text"}]
)
# Add objects
-adapter.add_objects(
+store.add_objects(
objects=[{"text": "Hello world"}],
vectors=[[0.1, 0.2, ...]]
)
```
-#### QdrantAdapter
+#### QdrantStore
High-performance Rust-based vector database.
@@ -306,16 +306,16 @@ High-performance Rust-based vector database.
**Example:**
```python
-from semantica.vector_store import QdrantAdapter
+from semantica.vector_store import QdrantStore
-adapter = QdrantAdapter(url="http://localhost:6333")
-adapter.connect()
+store = QdrantStore(url="http://localhost:6333")
+store.connect()
# Create collection
-collection = adapter.create_collection("my-collection", dimension=768)
+collection = store.create_collection("my-collection", dimension=768)
# Upsert with payload
-adapter.upsert_vectors(
+store.upsert_vectors(
collection,
vectors=[[0.1, 0.2, ...], ...],
ids=["vec_1", "vec_2"],
@@ -323,7 +323,7 @@ adapter.upsert_vectors(
)
```
-#### MilvusAdapter
+#### MilvusStore
Scalable cloud-native vector database.
@@ -335,20 +335,20 @@ Scalable cloud-native vector database.
**Example:**
```python
-from semantica.vector_store import MilvusAdapter
+from semantica.vector_store import MilvusStore
-adapter = MilvusAdapter(host="localhost", port="19530")
-adapter.connect()
+store = MilvusStore(host="localhost", port="19530")
+store.connect()
# Create collection
-collection = adapter.create_collection(
+collection = store.create_collection(
"my-collection",
dimension=768,
metric_type="L2"
)
# Insert vectors
-adapter.insert_vectors(collection, vectors, ids)
+store.insert_vectors(collection, vectors, ids)
```
---
diff --git a/semantica/embeddings/__init__.py b/semantica/embeddings/__init__.py
index 55ee6879..f5c1b66e 100644
--- a/semantica/embeddings/__init__.py
+++ b/semantica/embeddings/__init__.py
@@ -24,7 +24,7 @@ Pooling Strategies:
- Attention-based Pooling: Softmax-weighted sum using dot product attention scores
- Hierarchical Pooling: Two-level pooling (chunk-level then global-level mean pooling)
-Provider Adapters:
+Provider Stores:
- OpenAI API Integration: REST API-based embedding generation
- BGE Model Integration: Sentence-transformers wrapper for BAAI General Embedding models
- FastEmbed Integration: Fast and efficient embedding generation using FastEmbed library
@@ -93,13 +93,13 @@ from .pooling_strategies import (
PoolingStrategyFactory,
)
from .graph_embedding_manager import GraphEmbeddingManager
-from .provider_adapters import (
- BGEAdapter,
- FastEmbedAdapter,
- LlamaAdapter,
- OpenAIAdapter,
- ProviderAdapter,
- ProviderAdapterFactory,
+from .provider_stores import (
+ BGEStore,
+ FastEmbedStore,
+ LlamaStore,
+ OpenAIStore,
+ ProviderStore,
+ ProviderStoreFactory,
)
from .vector_embedding_manager import VectorEmbeddingManager
from .registry import MethodRegistry, method_registry
@@ -109,13 +109,13 @@ __all__ = [
# Core Classes
"EmbeddingGenerator",
"TextEmbedder",
- # Provider adapters
- "ProviderAdapter",
- "OpenAIAdapter",
- "BGEAdapter",
- "FastEmbedAdapter",
- "LlamaAdapter",
- "ProviderAdapterFactory",
+ # Provider stores
+ "ProviderStore",
+ "ProviderStoreFactory",
+ "OpenAIStore",
+ "BGEStore",
+ "FastEmbedStore",
+ "LlamaStore",
# Embedding managers
"VectorEmbeddingManager",
"GraphEmbeddingManager",
diff --git a/semantica/embeddings/embeddings_usage.md b/semantica/embeddings/embeddings_usage.md
index ff03cb06..5a7ce4bc 100644
--- a/semantica/embeddings/embeddings_usage.md
+++ b/semantica/embeddings/embeddings_usage.md
@@ -9,7 +9,7 @@ This guide demonstrates how to use the embeddings module for generating and mana
3. [Checking Embedding Methods](#checking-embedding-methods)
4. [Pooling Strategies](#pooling-strategies)
5. [Similarity Calculation](#similarity-calculation)
-6. [Provider Adapters](#provider-adapters)
+6. [Provider Stores](#provider-stores)
7. [Vector Embedding Manager](#vector-embedding-manager)
8. [Graph Embedding Manager](#graph-embedding-manager)
9. [Using Methods](#using-methods)
@@ -340,77 +340,77 @@ sim = calculate_similarity(emb1, emb2, method="cosine")
sim = calculate_similarity(emb1, emb2, method="euclidean")
```
-## Provider Adapters
+## Provider Stores
### OpenAI Embeddings
```python
-from semantica.embeddings import OpenAIAdapter
+from semantica.embeddings import OpenAIStore
-# Create OpenAI adapter
-adapter = OpenAIAdapter(
+# Create OpenAI store
+store = OpenAIStore(
api_key="your-api-key",
model="text-embedding-3-small"
)
# Generate embedding
-embedding = adapter.embed("Hello world")
+embedding = store.embed("Hello world")
print(f"OpenAI embedding shape: {embedding.shape}")
```
### BGE Embeddings
```python
-from semantica.embeddings import BGEAdapter
+from semantica.embeddings import BGEStore
-# Create BGE adapter
-adapter = BGEAdapter(
+# Create BGE store
+store = BGEStore(
model_name="BAAI/bge-small-en-v1.5"
)
# Generate embedding
-embedding = adapter.embed("Hello world")
+embedding = store.embed("Hello world")
```
### FastEmbed Embeddings
```python
-from semantica.embeddings import FastEmbedAdapter
+from semantica.embeddings import FastEmbedStore
-# Create FastEmbed adapter
-adapter = FastEmbedAdapter(
+# Create FastEmbed store
+store = FastEmbedStore(
model_name="BAAI/bge-small-en-v1.5"
)
# Single embedding
-embedding = adapter.embed("Hello world")
+embedding = store.embed("Hello world")
print(f"FastEmbed embedding shape: {embedding.shape}")
# Batch embeddings (FastEmbed is optimized for batch processing)
texts = ["text1", "text2", "text3"]
-embeddings = adapter.embed_batch(texts)
+embeddings = store.embed_batch(texts)
print(f"Batch embeddings shape: {embeddings.shape}")
```
### Provider Factory
```python
-from semantica.embeddings import ProviderAdapterFactory
+from semantica.embeddings import ProviderStoreFactory
# Create provider using factory
-adapter = ProviderAdapterFactory.create(
+store = ProviderStoreFactory.create(
"openai",
api_key="your-api-key"
)
-embedding = adapter.embed("Hello world")
+embedding = store.embed("Hello world")
-# Create FastEmbed adapter using factory
-fastembed_adapter = ProviderAdapterFactory.create(
+# Create FastEmbed store using factory
+fastembed_store = ProviderStoreFactory.create(
"fastembed",
model_name="BAAI/bge-small-en-v1.5"
)
-embedding = fastembed_adapter.embed("Hello world")
+embedding = fastembed_store.embed("Hello world")
```
## Vector Embedding Manager
diff --git a/semantica/embeddings/provider_adapters.py b/semantica/embeddings/provider_stores.py
similarity index 82%
rename from semantica/embeddings/provider_adapters.py
rename to semantica/embeddings/provider_stores.py
index e32a8bcb..e91228cd 100644
--- a/semantica/embeddings/provider_adapters.py
+++ b/semantica/embeddings/provider_stores.py
@@ -1,7 +1,7 @@
"""
-Provider adapters for Semantica framework.
+Provider stores for Semantica framework.
-This module provides adapters for various embedding providers
+This module provides stores for various embedding providers
like OpenAI, BGE, and Llama.
"""
@@ -14,12 +14,12 @@ from ..utils.exceptions import ProcessingError
from ..utils.logging import get_logger
-class ProviderAdapter:
- """Base class for embedding provider adapters."""
+class ProviderStore:
+ """Base class for embedding provider stores."""
def __init__(self, **config):
- """Initialize provider adapter."""
- self.logger = get_logger("provider_adapter")
+ """Initialize provider store."""
+ self.logger = get_logger("provider_store")
self.config = config
def embed(self, text: str, **options) -> np.ndarray:
@@ -49,11 +49,11 @@ class ProviderAdapter:
return np.array([self.embed(text, **options) for text in texts])
-class OpenAIAdapter(ProviderAdapter):
- """OpenAI embedding API adapter."""
+class OpenAIStore(ProviderStore):
+ """OpenAI embedding API store."""
def __init__(self, **config):
- """Initialize OpenAI adapter."""
+ """Initialize OpenAI store."""
super().__init__(**config)
self.api_key = config.get("api_key") or os.getenv("OPENAI_API_KEY")
@@ -95,11 +95,11 @@ class OpenAIAdapter(ProviderAdapter):
raise ProcessingError(f"Failed to get OpenAI embedding: {e}")
-class BGEAdapter(ProviderAdapter):
- """BGE (BAAI General Embedding) model adapter."""
+class BGEStore(ProviderStore):
+ """BGE (BAAI General Embedding) model store."""
def __init__(self, **config):
- """Initialize BGE adapter."""
+ """Initialize BGE store."""
super().__init__(**config)
self.model_name = config.get("model_name", "BAAI/bge-small-en-v1.5")
@@ -141,11 +141,11 @@ class BGEAdapter(ProviderAdapter):
raise ProcessingError(f"Failed to get BGE embedding: {e}")
-class LlamaAdapter(ProviderAdapter):
- """Llama embedding model adapter."""
+class LlamaStore(ProviderStore):
+ """Llama embedding model store."""
def __init__(self, **config):
- """Initialize Llama adapter."""
+ """Initialize Llama store."""
super().__init__(**config)
self.model_name = config.get("model_name")
@@ -157,7 +157,7 @@ class LlamaAdapter(ProviderAdapter):
"""Initialize Llama model."""
# Note: Llama embedding models typically require custom setup
# This is a placeholder for integration
- self.logger.warning("Llama adapter requires custom model setup")
+ self.logger.warning("Llama store requires custom model setup")
def embed(self, text: str, **options) -> np.ndarray:
"""
@@ -175,7 +175,7 @@ class LlamaAdapter(ProviderAdapter):
# Placeholder - would require actual Llama model implementation
# For now, return a placeholder embedding
- self.logger.warning("Llama adapter using placeholder implementation")
+ self.logger.warning("Llama store using placeholder implementation")
# Generate a placeholder embedding (same dimension as typical embeddings)
embedding_dim = 768 # Default Llama embedding dimension
@@ -191,11 +191,11 @@ class LlamaAdapter(ProviderAdapter):
return placeholder
-class FastEmbedAdapter(ProviderAdapter):
- """FastEmbed adapter for fast and efficient embedding generation."""
+class FastEmbedStore(ProviderStore):
+ """FastEmbed store for fast and efficient embedding generation."""
def __init__(self, **config):
- """Initialize FastEmbed adapter."""
+ """Initialize FastEmbed store."""
super().__init__(**config)
self.model_name = config.get("model_name", "BAAI/bge-small-en-v1.5")
@@ -266,30 +266,29 @@ class FastEmbedAdapter(ProviderAdapter):
raise ProcessingError(f"Failed to get FastEmbed batch embeddings: {e}")
-class ProviderAdapterFactory:
- """Factory for creating provider adapters."""
+class ProviderStoreFactory:
+ """Factory for creating provider stores."""
@staticmethod
- def create(provider: str, **config) -> ProviderAdapter:
+ def create(provider: str, **config) -> Any:
"""
- Create provider adapter.
+ Create provider store.
Args:
- provider: Provider name ("openai", "bge", "llama", "fastembed")
+ provider: Provider name (openai, bge, fastembed)
**config: Provider configuration
Returns:
- ProviderAdapter: Provider adapter instance
+ ProviderStore: Provider store instance
"""
providers = {
- "openai": OpenAIAdapter,
- "bge": BGEAdapter,
- "llama": LlamaAdapter,
- "fastembed": FastEmbedAdapter,
+ "openai": OpenAIStore,
+ "bge": BGEStore,
+ "fastembed": FastEmbedStore,
}
- adapter_class = providers.get(provider.lower())
- if not adapter_class:
- raise ProcessingError(f"Unsupported provider: {provider}")
+ store_class = providers.get(provider.lower())
+ if not store_class:
+ raise ValueError(f"Unsupported provider: {provider}")
- return adapter_class(**config)
+ return store_class(**config)
diff --git a/semantica/embeddings/registry.py b/semantica/embeddings/registry.py
index c5d58c5d..f5376ef9 100644
--- a/semantica/embeddings/registry.py
+++ b/semantica/embeddings/registry.py
@@ -13,7 +13,7 @@ Supported Registration Types:
* "multimodal": Multimodal embedding methods
* "optimization": Embedding optimization methods
* "pooling": Pooling strategy methods
- * "provider": Provider adapter methods
+ * "provider": Provider store methods
* "similarity": Similarity calculation methods
Algorithms Used:
diff --git a/semantica/graph_store/__init__.py b/semantica/graph_store/__init__.py
index aea23f77..b8e471b4 100644
--- a/semantica/graph_store/__init__.py
+++ b/semantica/graph_store/__init__.py
@@ -8,12 +8,12 @@ and FalkorDB for storing and querying knowledge graphs.
Algorithms Used:
Graph Store Management:
- - Store Registration: Store type detection, adapter factory pattern, configuration management, default store selection
- - Adapter Pattern: Unified interface for multiple backends (Neo4j, FalkorDB), adapter instantiation, backend-specific operation delegation
+ - Store Registration: Store type detection, store factory pattern, configuration management, default store selection
+ - Backend Pattern: Unified interface for multiple backends (Neo4j, FalkorDB), backend instantiation, backend-specific operation delegation
- Store Selection: Default store resolution, store ID lookup, store validation
Node and Relationship Operations:
- - Node Creation: Single node insertion, batch node insertion, property validation, label management, adapter delegation
+ - Node Creation: Single node insertion, batch node insertion, property validation, label management, backend delegation
- Node Retrieval: Pattern matching (label/property filtering), Cypher query construction, result extraction, node reconstruction
- Node Update: Property update, label modification, atomic update operations, conflict detection
- Node Deletion: Node matching, cascade deletion (optional), deletion operation delegation, result verification
@@ -35,9 +35,9 @@ Graph Analytics:
- Path Algorithms: Shortest path, all shortest paths, Dijkstra, A* pathfinding
- Similarity: Node similarity, Jaccard similarity, cosine similarity
-Store Adapters:
- - Neo4j Adapter: Official Neo4j Python driver, Bolt protocol communication, transaction support, multi-database support, APOC procedures
- - FalkorDB Adapter: Redis-based graph database, sparse matrix representation, linear algebra queries, OpenCypher support, ultra-fast performance
+Store Backends:
+ - Neo4j Store: Official Neo4j Python driver, Bolt protocol communication, transaction support, multi-database support, APOC procedures
+ - FalkorDB Store: Redis-based graph database, sparse matrix representation, linear algebra queries, OpenCypher support, ultra-fast performance
Bulk Operations:
- Batch Processing: Chunking algorithm (fixed-size batch creation), batch size optimization, memory management for large datasets
@@ -59,8 +59,8 @@ Key Features:
Main Classes:
- GraphStore: Main graph store interface
- GraphManager: Graph store management and operations
- - Neo4jAdapter: Neo4j integration adapter
- - FalkorDBAdapter: FalkorDB integration adapter
+ - Neo4jStore: Neo4j integration store
+ - FalkorDBStore: FalkorDB integration store
- NodeManager: Node CRUD operations
- RelationshipManager: Relationship CRUD operations
- QueryEngine: Cypher query execution and optimization
@@ -94,19 +94,18 @@ License: MIT
"""
from .config import GraphStoreConfig, graph_store_config
-from .falkordb_adapter import (
- FalkorDBAdapter,
+from .falkordb_store import (
+ FalkorDBStore,
FalkorDBClient,
FalkorDBGraph,
- FalkorDBQuery,
)
from .graph_store import (
- GraphAnalytics,
GraphManager,
GraphStore,
NodeManager,
QueryEngine,
RelationshipManager,
+ GraphAnalytics,
)
from .methods import (
create_node,
@@ -126,7 +125,11 @@ from .methods import (
update_node,
update_relationship,
)
-from .neo4j_adapter import Neo4jAdapter, Neo4jDriver, Neo4jSession, Neo4jTransaction
+from .neo4j_store import (
+ Neo4jStore,
+ Neo4jDriver,
+ Neo4jTransaction,
+)
from .registry import MethodRegistry, method_registry
__all__ = [
@@ -138,15 +141,13 @@ __all__ = [
"QueryEngine",
"GraphAnalytics",
# Neo4j
- "Neo4jAdapter",
+ "Neo4jStore",
"Neo4jDriver",
- "Neo4jSession",
"Neo4jTransaction",
# FalkorDB
- "FalkorDBAdapter",
+ "FalkorDBStore",
"FalkorDBClient",
"FalkorDBGraph",
- "FalkorDBQuery",
# Convenience functions
"create_node",
"create_nodes",
diff --git a/semantica/graph_store/falkordb_adapter.py b/semantica/graph_store/falkordb_store.py
similarity index 97%
rename from semantica/graph_store/falkordb_adapter.py
rename to semantica/graph_store/falkordb_store.py
index 71ebb7cd..982326ce 100644
--- a/semantica/graph_store/falkordb_adapter.py
+++ b/semantica/graph_store/falkordb_store.py
@@ -1,5 +1,5 @@
"""
-FalkorDB Adapter Module
+FalkorDB Store Module
This module provides FalkorDB integration for ultra-fast property graph storage and
OpenCypher querying in the Semantica framework. FalkorDB is a high-performance
@@ -18,19 +18,19 @@ Key Features:
- Optional dependency handling
Main Classes:
- - FalkorDBAdapter: Main FalkorDB adapter for graph operations
+ - FalkorDBStore: Main FalkorDB store for graph operations
- FalkorDBClient: FalkorDB client wrapper
- FalkorDBGraph: Graph wrapper with operations
- FalkorDBQuery: Query execution wrapper
Example Usage:
- >>> from semantica.graph_store import FalkorDBAdapter
- >>> adapter = FalkorDBAdapter(host="localhost", port=6379)
- >>> adapter.connect()
- >>> graph = adapter.select_graph("MotoGP")
- >>> adapter.create_node(["Rider"], {"name": "Valentino Rossi"})
- >>> results = adapter.execute_query("MATCH (r:Rider) RETURN r.name")
- >>> adapter.close()
+ >>> from semantica.graph_store import FalkorDBStore
+ >>> store = FalkorDBStore(host="localhost", port=6379)
+ >>> store.connect()
+ >>> graph = store.select_graph("MotoGP")
+ >>> store.create_node(["Rider"], {"name": "Valentino Rossi"})
+ >>> results = store.execute_query("MATCH (r:Rider) RETURN r.name")
+ >>> store.close()
Author: Semantica Contributors
License: MIT
@@ -177,9 +177,9 @@ class FalkorDBQuery:
return {}
-class FalkorDBAdapter:
+class FalkorDBStore:
"""
- FalkorDB adapter for ultra-fast property graph storage and OpenCypher querying.
+ FalkorDB store for ultra-fast property graph storage and OpenCypher querying.
• FalkorDB connection and authentication
• Multi-graph support
@@ -200,7 +200,7 @@ class FalkorDBAdapter:
**config,
):
"""
- Initialize FalkorDB adapter.
+ Initialize FalkorDB store.
Args:
host: FalkorDB/Redis host
@@ -209,7 +209,7 @@ class FalkorDBAdapter:
graph_name: Default graph name
**config: Additional configuration options
"""
- self.logger = get_logger("falkordb_adapter")
+ self.logger = get_logger("falkordb_store")
self.config = config
self.progress_tracker = get_progress_tracker()
@@ -320,7 +320,7 @@ class FalkorDBAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="FalkorDBAdapter",
+ submodule="FalkorDBStore",
message=f"Creating node with labels {labels}",
)
@@ -377,7 +377,7 @@ class FalkorDBAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="FalkorDBAdapter",
+ submodule="FalkorDBStore",
message=f"Creating {len(nodes)} nodes in batch",
)
@@ -581,7 +581,7 @@ class FalkorDBAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="FalkorDBAdapter",
+ submodule="FalkorDBStore",
message=f"Creating relationship [{rel_type}]",
)
@@ -747,7 +747,7 @@ class FalkorDBAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="FalkorDBAdapter",
+ submodule="FalkorDBStore",
message="Executing OpenCypher query",
)
diff --git a/semantica/graph_store/graph_store.py b/semantica/graph_store/graph_store.py
index 13d28019..cd2d2e98 100644
--- a/semantica/graph_store/graph_store.py
+++ b/semantica/graph_store/graph_store.py
@@ -43,14 +43,14 @@ from .config import graph_store_config
class NodeManager:
"""Manager for node CRUD operations."""
- def __init__(self, adapter: Any):
+ def __init__(self, backend: Any):
"""
Initialize node manager.
Args:
- adapter: Graph database adapter instance
+ backend: Graph database backend instance
"""
- self.adapter = adapter
+ self.backend = backend
self.logger = get_logger("node_manager")
def create(
@@ -70,7 +70,7 @@ class NodeManager:
Returns:
Created node information
"""
- return self.adapter.create_node(labels, properties, **options)
+ return self.backend.create_node(labels, properties, **options)
def create_batch(
self,
@@ -87,7 +87,7 @@ class NodeManager:
Returns:
List of created node information
"""
- return self.adapter.create_nodes(nodes, **options)
+ return self.backend.create_nodes(nodes, **options)
def get(
self,
@@ -111,8 +111,8 @@ class NodeManager:
Node or list of nodes
"""
if node_id is not None:
- return self.adapter.get_node(node_id, **options)
- return self.adapter.get_nodes(labels, properties, limit, **options)
+ return self.backend.get_node(node_id, **options)
+ return self.backend.get_nodes(labels, properties, limit, **options)
def update(
self,
@@ -133,7 +133,7 @@ class NodeManager:
Returns:
Updated node information
"""
- return self.adapter.update_node(node_id, properties, merge, **options)
+ return self.backend.update_node(node_id, properties, merge, **options)
def delete(
self,
@@ -152,20 +152,20 @@ class NodeManager:
Returns:
True if deleted
"""
- return self.adapter.delete_node(node_id, detach, **options)
+ return self.backend.delete_node(node_id, detach, **options)
class RelationshipManager:
"""Manager for relationship CRUD operations."""
- def __init__(self, adapter: Any):
+ def __init__(self, backend: Any):
"""
Initialize relationship manager.
Args:
- adapter: Graph database adapter instance
+ backend: Graph database backend instance
"""
- self.adapter = adapter
+ self.backend = backend
self.logger = get_logger("relationship_manager")
def create(
@@ -189,7 +189,7 @@ class RelationshipManager:
Returns:
Created relationship information
"""
- return self.adapter.create_relationship(
+ return self.backend.create_relationship(
start_node_id, end_node_id, rel_type, properties, **options
)
@@ -214,7 +214,7 @@ class RelationshipManager:
Returns:
List of relationships
"""
- return self.adapter.get_relationships(node_id, rel_type, direction, limit, **options)
+ return self.backend.get_relationships(node_id, rel_type, direction, limit, **options)
def delete(
self,
@@ -231,20 +231,20 @@ class RelationshipManager:
Returns:
True if deleted
"""
- return self.adapter.delete_relationship(rel_id, **options)
+ return self.backend.delete_relationship(rel_id, **options)
class QueryEngine:
"""Engine for query execution and optimization."""
- def __init__(self, adapter: Any):
+ def __init__(self, backend: Any):
"""
Initialize query engine.
Args:
- adapter: Graph database adapter instance
+ backend: Graph database backend instance
"""
- self.adapter = adapter
+ self.backend = backend
self.logger = get_logger("query_engine")
self._cache: Dict[str, Any] = {}
self._cache_enabled = True
@@ -275,7 +275,7 @@ class QueryEngine:
return self._cache[cache_key]
# Execute query
- result = self.adapter.execute_query(query, parameters, **options)
+ result = self.backend.execute_query(query, parameters, **options)
# Cache result
if use_cache and self._cache_enabled:
@@ -309,14 +309,14 @@ class QueryEngine:
class GraphAnalytics:
"""Graph analytics and algorithms."""
- def __init__(self, adapter: Any):
+ def __init__(self, backend: Any):
"""
Initialize graph analytics.
Args:
- adapter: Graph database adapter instance
+ backend: Graph database backend instance
"""
- self.adapter = adapter
+ self.backend = backend
self.logger = get_logger("graph_analytics")
def shortest_path(
@@ -340,7 +340,7 @@ class GraphAnalytics:
Returns:
Path information or None
"""
- return self.adapter.shortest_path(start_node_id, end_node_id, rel_type, max_depth, **options)
+ return self.backend.shortest_path(start_node_id, end_node_id, rel_type, max_depth, **options)
def get_neighbors(
self,
@@ -363,7 +363,7 @@ class GraphAnalytics:
Returns:
List of neighboring nodes
"""
- return self.adapter.get_neighbors(node_id, rel_type, direction, depth, **options)
+ return self.backend.get_neighbors(node_id, rel_type, direction, depth, **options)
def degree_centrality(
self,
@@ -418,7 +418,7 @@ class GraphAnalytics:
ORDER BY degree DESC
"""
- result = self.adapter.execute_query(query)
+ result = self.backend.execute_query(query)
return result.get("records", [])
def connected_components(
@@ -439,46 +439,51 @@ class GraphAnalytics:
Returns:
Component information
"""
- self.logger.warning(
- "Full connected components algorithm requires graph data science extensions. "
- "Returning basic component approximation."
- )
-
- # Get all nodes and their connections
- if labels:
- label_str = ":".join(labels)
- query = f"MATCH (n:{label_str})-[r]-(m) RETURN DISTINCT id(n) as node_id, id(m) as connected_id"
+ backend_type = type(self.backend).__name__
+
+ if "Neo4j" in backend_type:
+ query = """
+ CALL gds.wcc.stream({
+ nodeProjection: $label,
+ relationshipProjection: '*'
+ })
+ YIELD nodeId, componentId
+ RETURN componentId, collect(nodeId) as nodes
+ """
+ params = {"label": labels[0] if labels else "*"}
+ result = self.backend.execute_query(query, params)
+ return [{"component": r["componentId"], "nodes": r["nodes"]} for r in result]
+
+ elif "NetworkX" in backend_type:
+ import networkx as nx
+ G = self.backend.graph
+ components = list(nx.connected_components(G))
+ return [{"component": i, "nodes": list(c)} for i, c in enumerate(components)]
+
else:
- query = "MATCH (n)-[r]-(m) RETURN DISTINCT id(n) as node_id, id(m) as connected_id"
-
- result = self.adapter.execute_query(query)
-
- return {
- "message": "Connected components approximation",
- "connections": result.get("records", []),
- }
+ raise NotImplementedError(f"connected_components not implemented for {backend_type}")
class GraphManager:
"""Manager for graph store operations."""
- def __init__(self, adapter: Any):
+ def __init__(self, backend: Any):
"""
Initialize graph manager.
Args:
- adapter: Graph database adapter instance
+ backend: Graph database backend instance
"""
- self.adapter = adapter
+ self.backend = backend
self.logger = get_logger("graph_manager")
- self.nodes = NodeManager(adapter)
- self.relationships = RelationshipManager(adapter)
- self.query_engine = QueryEngine(adapter)
- self.analytics = GraphAnalytics(adapter)
+ self.nodes = NodeManager(backend)
+ self.relationships = RelationshipManager(backend)
+ self.query_engine = QueryEngine(backend)
+ self.analytics = GraphAnalytics(backend)
def get_stats(self) -> Dict[str, Any]:
"""Get graph statistics."""
- return self.adapter.get_stats()
+ return self.backend.get_stats()
def create_index(
self,
@@ -499,7 +504,7 @@ class GraphManager:
Returns:
True if created
"""
- return self.adapter.create_index(label, property_name, index_type, **options)
+ return self.backend.create_index(label, property_name, index_type, **options)
class GraphStore:
@@ -529,29 +534,29 @@ class GraphStore:
self.backend = backend or config.get("backend") or graph_store_config.get("default_backend", "neo4j")
self.config = config
- # Initialize adapter
- self._adapter = None
+ # Initialize store backend
+ self._store_backend = None
self._manager = None
- self._initialize_adapter()
+ self._initialize_store_backend()
- def _initialize_adapter(self) -> None:
- """Initialize the appropriate adapter based on backend."""
+ def _initialize_store_backend(self) -> None:
+ """Initialize the appropriate store backend based on backend type."""
if self.backend == "neo4j":
- from .neo4j_adapter import Neo4jAdapter
+ from .neo4j_store import Neo4jStore
neo4j_config = graph_store_config.get_neo4j_config()
neo4j_config.update(self.config)
- self._adapter = Neo4jAdapter(**neo4j_config)
+ self._store_backend = Neo4jStore(**neo4j_config)
elif self.backend == "falkordb":
- from .falkordb_adapter import FalkorDBAdapter
+ from .falkordb_store import FalkorDBStore
falkordb_config = graph_store_config.get_falkordb_config()
falkordb_config.update(self.config)
- self._adapter = FalkorDBAdapter(**falkordb_config)
+ self._store_backend = FalkorDBStore(**falkordb_config)
else:
raise ValidationError(f"Unknown backend: {self.backend}")
- self._manager = GraphManager(self._adapter)
+ self._manager = GraphManager(self._store_backend)
def connect(self, **options) -> bool:
"""
@@ -563,12 +568,12 @@ class GraphStore:
Returns:
True if connected
"""
- return self._adapter.connect(**options)
+ return self._store_backend.connect(**options)
def close(self) -> None:
"""Close connection to the graph database."""
- if self._adapter:
- self._adapter.close()
+ if self._store_backend:
+ self._store_backend.close()
def __enter__(self):
"""Context manager entry."""
diff --git a/semantica/graph_store/neo4j_adapter.py b/semantica/graph_store/neo4j_store.py
similarity index 97%
rename from semantica/graph_store/neo4j_adapter.py
rename to semantica/graph_store/neo4j_store.py
index be8fcd8f..12060936 100644
--- a/semantica/graph_store/neo4j_adapter.py
+++ b/semantica/graph_store/neo4j_store.py
@@ -1,5 +1,5 @@
"""
-Neo4j Adapter Module
+Neo4j Store Module
This module provides Neo4j graph database integration for property graph storage and
Cypher querying in the Semantica framework, supporting full CRUD operations,
@@ -16,18 +16,18 @@ Key Features:
- Optional dependency handling
Main Classes:
- - Neo4jAdapter: Main Neo4j adapter for graph operations
+ - Neo4jStore: Main Neo4j store for graph operations
- Neo4jDriver: Neo4j driver wrapper
- Neo4jSession: Session management wrapper
- Neo4jTransaction: Transaction wrapper
Example Usage:
- >>> from semantica.graph_store import Neo4jAdapter
- >>> adapter = Neo4jAdapter(uri="bolt://localhost:7687", user="neo4j", password="password")
- >>> adapter.connect()
- >>> node_id = adapter.create_node(labels=["Person"], properties={"name": "Alice"})
- >>> results = adapter.execute_query("MATCH (p:Person) RETURN p.name")
- >>> adapter.close()
+ >>> from semantica.graph_store import Neo4jStore
+ >>> store = Neo4jStore(uri="bolt://localhost:7687", user="neo4j", password="password")
+ >>> store.connect()
+ >>> node_id = store.create_node(labels=["Person"], properties={"name": "Alice"})
+ >>> results = store.execute_query("MATCH (p:Person) RETURN p.name")
+ >>> store.close()
Author: Semantica Contributors
License: MIT
@@ -218,9 +218,9 @@ class Neo4jTransaction:
self.commit()
-class Neo4jAdapter:
+class Neo4jStore:
"""
- Neo4j adapter for property graph storage and Cypher querying.
+ Neo4j store for property graph storage and Cypher querying.
• Neo4j connection and authentication
• Node and relationship CRUD operations
@@ -240,7 +240,7 @@ class Neo4jAdapter:
**config,
):
"""
- Initialize Neo4j adapter.
+ Initialize Neo4j store.
Args:
uri: Neo4j connection URI (bolt://localhost:7687)
@@ -249,7 +249,7 @@ class Neo4jAdapter:
database: Database name
**config: Additional configuration options
"""
- self.logger = get_logger("neo4j_adapter")
+ self.logger = get_logger("neo4j_store")
self.config = config
self.progress_tracker = get_progress_tracker()
@@ -358,7 +358,7 @@ class Neo4jAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="Neo4jAdapter",
+ submodule="Neo4jStore",
message=f"Creating node with labels {labels}",
)
@@ -409,7 +409,7 @@ class Neo4jAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="Neo4jAdapter",
+ submodule="Neo4jStore",
message=f"Creating {len(nodes)} nodes in batch",
)
@@ -626,7 +626,7 @@ class Neo4jAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="Neo4jAdapter",
+ submodule="Neo4jStore",
message=f"Creating relationship [{rel_type}]",
)
@@ -786,7 +786,7 @@ class Neo4jAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="graph_store",
- submodule="Neo4jAdapter",
+ submodule="Neo4jStore",
message="Executing Cypher query",
)
diff --git a/semantica/split/splitter.py b/semantica/split/splitter.py
index 3c7c0dd2..9a6865d2 100644
--- a/semantica/split/splitter.py
+++ b/semantica/split/splitter.py
@@ -13,7 +13,7 @@ Algorithms Used:
- Strategy Pattern: Method selection and delegation
- Factory Pattern: Unified creation of appropriate splitter
- Fallback Chain: Automatic fallback to alternative methods
- - Adapter Pattern: Integration with existing chunker classes
+ - Integration Pattern: Integration with existing chunker classes
Key Features:
- Unified interface for all splitting methods
diff --git a/semantica/triplet_store/__init__.py b/semantica/triplet_store/__init__.py
index a37befe2..34de462c 100644
--- a/semantica/triplet_store/__init__.py
+++ b/semantica/triplet_store/__init__.py
@@ -8,12 +8,12 @@ with unified interfaces.
Algorithms Used:
Triplet Store Management:
- - Store Registration: Store type detection, adapter factory pattern, configuration management, default store selection
- - Adapter Pattern: Unified interface for multiple backends (Blazegraph, Jena, RDF4J, Virtuoso), adapter instantiation, backend-specific operation delegation
+ - Store Registration: Store type detection, store factory pattern, configuration management, default store selection
+ - Backend Pattern: Unified interface for multiple backends (Blazegraph, Jena, RDF4J, Virtuoso), store instantiation, backend-specific operation delegation
- Store Selection: Default store resolution, store ID lookup, store validation
CRUD Operations:
- - Triplet Addition: Single triplet insertion, batch triplet insertion, triplet validation (subject/predicate/object checking, confidence validation), adapter delegation
+ - Triplet Addition: Single triplet insertion, batch triplet insertion, triplet validation (subject/predicate/object checking, confidence validation), store delegation
- Triplet Retrieval: Pattern matching (subject/predicate/object filtering), SPARQL query construction, result binding extraction, triplet reconstruction
- Triplet Deletion: Triplet matching, deletion operation delegation, result verification
- Triplet Update: Delete-then-add pattern, atomic update operations, conflict detection
@@ -37,11 +37,11 @@ Query Optimization:
- Execution Step Identification: Query parsing for step detection, step sequence construction, optimization opportunity detection
- Query Rewriting: Whitespace normalization, LIMIT injection, query simplification
-Store Adapters:
- - Blazegraph Adapter: HTTP-based SPARQL endpoint communication, namespace management, graph management, bulk load via INSERT DATA, authentication handling
- - Jena Adapter: rdflib integration, SPARQLStore for remote endpoints, in-memory graph support, model/dataset management, RDF serialization (Turtle, RDF/XML, N3), inference support
- - RDF4J Adapter: RDF4J repository connection, SPARQL endpoint communication, transaction support, bulk operations
- - Virtuoso Adapter: Virtuoso SPARQL endpoint communication, SQL/SPARQL hybrid queries, bulk loading, transaction support
+Store Backends:
+ - Blazegraph Store: HTTP-based SPARQL endpoint communication, namespace management, graph management, bulk load via INSERT DATA, authentication handling
+ - Jena Store: rdflib integration, SPARQLStore for remote endpoints, in-memory graph support, model/dataset management, RDF serialization (Turtle, RDF/XML, N3), inference support
+ - RDF4J Store: RDF4J repository connection, SPARQL endpoint communication, transaction support, bulk operations
+ - Virtuoso Store: Virtuoso SPARQL endpoint communication, SQL/SPARQL hybrid queries, bulk loading, transaction support
Data Validation:
- Triplet Validation: Required field checking (subject, predicate, object), confidence range validation (0-1), URI format validation
@@ -49,9 +49,9 @@ Data Validation:
Performance Optimization:
- Batch Size Optimization: Configurable batch size, memory-aware batching, throughput-based optimization
- - Connection Pooling: Adapter-level connection management, connection reuse, connection lifecycle management
+ - Connection Pooling: Store-level connection management, connection reuse, connection lifecycle management
- Query Caching: Result caching for repeated queries, cache size management, cache hit optimization
- - Parallel Processing: Batch-level parallelization (when supported by adapter), concurrent batch processing
+ - Parallel Processing: Batch-level parallelization (when supported by store), concurrent batch processing
Key Features:
- Multi-backend support (Blazegraph, Jena, RDF4J, Virtuoso)
@@ -60,7 +60,7 @@ Key Features:
- Bulk data loading with progress tracking
- Query caching and optimization
- Transaction support
- - Store adapter pattern
+ - Store backend pattern
- Method registry for extensibility
- Configuration management with environment variables and config files
@@ -68,10 +68,10 @@ Main Classes:
- TripletManager: Main triplet 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
+ - BlazegraphStore: Blazegraph integration store
+ - JenaStore: Apache Jena integration store
+ - RDF4JStore: Eclipse RDF4J integration store
+ - VirtuosoStore: Virtuoso RDF store integration store
- TripletStore: Triplet store configuration dataclass
- QueryResult: Query result representation dataclass
- QueryPlan: Query execution plan dataclass
@@ -94,23 +94,23 @@ Example Usage:
>>> # Using convenience functions
>>> store = register_store("main", "blazegraph", "http://localhost:9999/blazegraph")
>>> result = add_triplet(triplet, store_id="main")
- >>> query_result = execute_query(sparql_query, store_adapter)
+ >>> query_result = execute_query(sparql_query, store)
>>> # Using classes directly
>>> manager = TripletManager()
>>> store = manager.register_store("main", "blazegraph", "http://localhost:9999/blazegraph")
>>> result = manager.add_triplet(triplet, store_id="main")
>>> from semantica.triplet_store import QueryEngine
>>> engine = QueryEngine()
- >>> query_result = engine.execute_query(sparql_query, store_adapter)
+ >>> query_result = engine.execute_query(sparql_query, store)
Author: Semantica Contributors
License: MIT
"""
-from .blazegraph_adapter import BlazegraphAdapter
+from .blazegraph_store import BlazegraphStore
from .bulk_loader import BulkLoader, LoadProgress
from .config import TripletStoreConfig, triplet_store_config
-from .jena_adapter import JenaAdapter
+from .jena_store import JenaStore
from .methods import (
add_triplet,
add_triplets,
@@ -127,20 +127,20 @@ from .methods import (
validate_triplets,
)
from .query_engine import QueryEngine, QueryPlan, QueryResult
-from .rdf4j_adapter import RDF4JAdapter
+from .rdf4j_store import RDF4JStore
from .registry import MethodRegistry, method_registry
from .triplet_manager import TripletManager, TripletStore
-from .virtuoso_adapter import VirtuosoAdapter
+from .virtuoso_store import VirtuosoStore
__all__ = [
# Triplet management
"TripletManager",
"TripletStore",
- # Store adapters
- "BlazegraphAdapter",
- "JenaAdapter",
- "RDF4JAdapter",
- "VirtuosoAdapter",
+ # Store backends
+ "BlazegraphStore",
+ "JenaStore",
+ "RDF4JStore",
+ "VirtuosoStore",
# Query engine
"QueryEngine",
"QueryResult",
diff --git a/semantica/triplet_store/blazegraph_adapter.py b/semantica/triplet_store/blazegraph_store.py
similarity index 94%
rename from semantica/triplet_store/blazegraph_adapter.py
rename to semantica/triplet_store/blazegraph_store.py
index 49b99357..a838b55c 100644
--- a/semantica/triplet_store/blazegraph_adapter.py
+++ b/semantica/triplet_store/blazegraph_store.py
@@ -1,5 +1,5 @@
"""
-Blazegraph Adapter Module
+Blazegraph Store Module
This module provides Blazegraph integration for RDF storage and SPARQL
querying, enabling connection to Blazegraph instances with namespace
@@ -14,14 +14,14 @@ Key Features:
- Performance optimization
Main Classes:
- - BlazegraphAdapter: Main Blazegraph integration adapter
+ - BlazegraphStore: Main Blazegraph integration store
Example Usage:
- >>> from semantica.triplet_store import BlazegraphAdapter
- >>> adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph", namespace="kb")
- >>> result = adapter.execute_sparql(sparql_query)
- >>> load_result = adapter.bulk_load(triplets)
- >>> namespace_result = adapter.create_namespace("new_namespace")
+ >>> from semantica.triplet_store import BlazegraphStore
+ >>> store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph", namespace="kb")
+ >>> result = store.execute_sparql(sparql_query)
+ >>> load_result = store.bulk_load(triplets)
+ >>> namespace_result = store.create_namespace("new_namespace")
Author: Semantica Contributors
License: MIT
@@ -38,9 +38,9 @@ from ..utils.logging import get_logger
from ..utils.progress_tracker import get_progress_tracker
-class BlazegraphAdapter:
+class BlazegraphStore:
"""
- Blazegraph triplet store adapter.
+ Blazegraph triplet store backend.
• Blazegraph connection and authentication
• SPARQL query execution
@@ -52,7 +52,7 @@ class BlazegraphAdapter:
def __init__(self, endpoint: str, **config):
"""
- Initialize Blazegraph adapter.
+ Initialize Blazegraph store.
Args:
endpoint: Blazegraph endpoint URL
@@ -62,7 +62,7 @@ class BlazegraphAdapter:
- password: Password for authentication
- timeout: Request timeout (default: 30)
"""
- self.logger = get_logger("blazegraph_adapter")
+ self.logger = get_logger("blazegraph_store")
self.config = config
self.progress_tracker = get_progress_tracker()
@@ -120,7 +120,7 @@ class BlazegraphAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="triplet_store",
- submodule="BlazegraphAdapter",
+ submodule="BlazegraphStore",
message="Executing SPARQL query on Blazegraph",
)
diff --git a/semantica/triplet_store/bulk_loader.py b/semantica/triplet_store/bulk_loader.py
index 0eb2be67..77065830 100644
--- a/semantica/triplet_store/bulk_loader.py
+++ b/semantica/triplet_store/bulk_loader.py
@@ -20,7 +20,7 @@ Main Classes:
Example Usage:
>>> from semantica.triplet_store import BulkLoader
>>> loader = BulkLoader(batch_size=1000, max_retries=3)
- >>> progress = loader.load_triplets(triplets, store_adapter)
+ >>> progress = loader.load_triplets(triplets, store)
>>> print(f"Loaded {progress.loaded_triplets}/{progress.total_triplets} triplets")
>>> validation = loader.validate_before_load(triplets)
@@ -87,14 +87,14 @@ class BulkLoader:
self.retry_delay = self.config.get("retry_delay", 1.0)
def load_triplets(
- self, triplets: List[Triplet], store_adapter: Any, **options
+ self, triplets: List[Triplet], store: Any, **options
) -> LoadProgress:
"""
Load triplets in bulk.
Args:
triplets: List of triplets to load
- store_adapter: Triplet store adapter instance
+ store: Triplet store backend instance
**options: Additional options:
- batch_size: Override default batch size
- progress_callback: Callback function for progress updates
@@ -139,13 +139,13 @@ class BulkLoader:
batch_loaded = 0
for attempt in range(self.max_retries):
try:
- if hasattr(store_adapter, "bulk_load"):
- result = store_adapter.bulk_load(batch, **options)
- elif hasattr(store_adapter, "add_triplets"):
- result = store_adapter.add_triplets(batch, **options)
+ if hasattr(store, "bulk_load"):
+ result = store.bulk_load(batch, **options)
+ elif hasattr(store, "add_triplets"):
+ result = store.add_triplets(batch, **options)
else:
raise ProcessingError(
- "Store adapter does not support bulk loading"
+ "Store backend does not support bulk loading"
)
batch_loaded = len(batch)
@@ -196,7 +196,7 @@ class BulkLoader:
estimated_remaining=estimated_remaining,
metadata={
"batch_size": batch_size,
- "store_type": store_adapter.__class__.__name__,
+ "store_type": store.__class__.__name__,
},
)
@@ -244,14 +244,14 @@ class BulkLoader:
raise
def load_from_file(
- self, file_path: str, store_adapter: Any, **options
+ self, file_path: str, store_backend: Any, **options
) -> LoadProgress:
"""
Load triplets from file.
Args:
file_path: Path to RDF file
- store_adapter: Triplet store adapter
+ store_backend: Triplet store backend
**options: Additional options:
- format: File format (turtle, ntriples, rdfxml)
- chunk_size: Chunk size for reading large files
@@ -275,14 +275,14 @@ class BulkLoader:
)
def load_from_stream(
- self, triplets_stream: Any, store_adapter: Any, **options
+ self, triplets_stream: Any, store_backend: Any, **options
) -> LoadProgress:
"""
Load triplets from stream.
Args:
triplets_stream: Stream of triplets
- store_adapter: Triplet store adapter
+ store_backend: Triplet store backend
**options: Additional options
Returns:
@@ -297,13 +297,13 @@ class BulkLoader:
if len(batch) >= self.batch_size:
# Load batch
- progress = self.load_triplets(batch, store_adapter, **options)
+ progress = self.load_triplets(batch, store_backend, **options)
total_loaded += progress.loaded_triplets
batch = []
# Load remaining triplets
if batch:
- progress = self.load_triplets(batch, store_adapter, **options)
+ progress = self.load_triplets(batch, store_backend, **options)
total_loaded += progress.loaded_triplets
return LoadProgress(
diff --git a/semantica/triplet_store/jena_adapter.py b/semantica/triplet_store/jena_store.py
similarity index 89%
rename from semantica/triplet_store/jena_adapter.py
rename to semantica/triplet_store/jena_store.py
index 43795a41..c69da5dc 100644
--- a/semantica/triplet_store/jena_adapter.py
+++ b/semantica/triplet_store/jena_store.py
@@ -1,5 +1,5 @@
"""
-Apache Jena Adapter Module
+Apache Jena Store Module
This module provides Apache Jena integration for RDF storage and SPARQL
querying, supporting both in-memory and remote Fuseki endpoints.
@@ -13,14 +13,14 @@ Key Features:
- rdflib integration with fallback
Main Classes:
- - JenaAdapter: Main Jena integration adapter
+ - JenaStore: Main Jena integration store
Example Usage:
- >>> from semantica.triplet_store import JenaAdapter
- >>> adapter = JenaAdapter(endpoint="http://localhost:3030/ds", dataset="default")
- >>> result = adapter.add_triplets(triplets)
- >>> query_result = adapter.execute_sparql(sparql_query)
- >>> rdf_turtle = adapter.serialize(format="turtle")
+ >>> from semantica.triplet_store import JenaStore
+ >>> store = JenaStore(endpoint="http://localhost:3030/ds", dataset="default")
+ >>> result = store.add_triplets(triplets)
+ >>> query_result = store.execute_sparql(sparql_query)
+ >>> rdf_turtle = store.serialize(format="turtle")
Author: Semantica Contributors
License: MIT
@@ -45,29 +45,23 @@ except ImportError:
RDF = None
-class JenaAdapter:
+class JenaStore:
"""
- Apache Jena adapter for triplet store operations.
+ Apache Jena store for triplet store operations.
- • Jena connection and configuration
- • SPARQL query execution
- • Model and dataset management
- • Inference and reasoning support
- • Performance optimization
- • Error handling and recovery
+ This class provides integration with Apache Jena and Fuseki, supporting
+ both remote SPARQL endpoints and local in-memory graphs via rdflib.
"""
- def __init__(self, **config):
+ def __init__(self, endpoint: Optional[str] = None, **config):
"""
- Initialize Jena adapter.
+ Initialize Jena store.
Args:
- **config: Configuration options:
- - endpoint: Jena Fuseki endpoint (optional)
- - dataset: Dataset name
- - enable_inference: Enable inference (default: False)
+ endpoint: SPARQL endpoint URL (e.g., http://localhost:3030/ds)
+ **config: Additional configuration options
"""
- self.logger = get_logger("jena_adapter")
+ self.logger = get_logger("jena_store")
self.config = config
self.progress_tracker = get_progress_tracker()
@@ -94,7 +88,7 @@ class JenaAdapter:
self.graph = Graph()
else:
self.logger.warning(
- "rdflib not available. Jena adapter will use basic operations."
+ "rdflib not available. Jena store will use basic operations."
)
self.graph = None
@@ -130,7 +124,7 @@ class JenaAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="triplet_store",
- submodule="JenaAdapter",
+ submodule="JenaStore",
message=f"Adding {len(triplets)} triplets to Jena model",
)
diff --git a/semantica/triplet_store/methods.py b/semantica/triplet_store/methods.py
index 262f4847..bd724be1 100644
--- a/semantica/triplet_store/methods.py
+++ b/semantica/triplet_store/methods.py
@@ -57,9 +57,9 @@ Validation:
Algorithms Used:
Store Registration:
- - Store Type Detection: Backend type identification, adapter factory pattern
+ - Store Type Detection: Backend type identification, store factory pattern
- Configuration Management: Store configuration storage, default store selection
- - Adapter Instantiation: Backend-specific adapter creation, connection initialization
+ - Store Instantiation: Backend-specific store creation, connection initialization
Triplet Operations:
- Triplet Validation: Required field checking, confidence validation, URI validation
@@ -102,7 +102,7 @@ Example Usage:
>>> from semantica.triplet_store.methods import register_store, add_triplet, execute_query
>>> store = register_store("main", "blazegraph", "http://localhost:9999/blazegraph", method="default")
>>> result = add_triplet(triplet, store_id="main", method="default")
- >>> query_result = execute_query(sparql_query, store_adapter, method="default")
+ >>> query_result = execute_query(sparql_query, store_backend, method="default")
"""
from typing import Any, Dict, List, Optional, Union
@@ -314,14 +314,14 @@ def update_triplet(
def execute_query(
- query: str, store_adapter: Any, method: str = "default", **options
+ query: str, store_backend: Any, method: str = "default", **options
) -> QueryResult:
"""
Execute SPARQL query.
Args:
query: SPARQL query string
- store_adapter: Triplet store adapter instance
+ store_backend: Triplet store backend instance
method: Query method name (default: "default")
**options: Additional options
@@ -331,11 +331,11 @@ def execute_query(
# Check registry for custom method
custom_method = method_registry.get("query", method)
if custom_method:
- return custom_method(query, store_adapter, **options)
+ return custom_method(query, store_backend, **options)
# Default implementation
engine = _get_query_engine()
- return engine.execute_query(query, store_adapter, **options)
+ return engine.execute_query(query, store_backend, **options)
def optimize_query(query: str, method: str = "default", **options) -> str:
@@ -376,14 +376,14 @@ def plan_query(query: str, **options) -> QueryPlan:
def bulk_load(
- triplets: List[Triplet], store_adapter: Any, method: str = "default", **options
+ triplets: List[Triplet], store_backend: Any, method: str = "default", **options
) -> LoadProgress:
"""
Load triplets in bulk.
Args:
triplets: List of triplets to load
- store_adapter: Triplet store adapter instance
+ store_backend: Triplet store backend instance
method: Loading method name (default: "default")
**options: Additional options
@@ -393,11 +393,11 @@ def bulk_load(
# Check registry for custom method
custom_method = method_registry.get("bulk_load", method)
if custom_method:
- return custom_method(triplets, store_adapter, **options)
+ return custom_method(triplets, store_backend, **options)
# Default implementation
loader = _get_bulk_loader()
- return loader.load_triplets(triplets, store_adapter, **options)
+ return loader.load_triplets(triplets, store_backend, **options)
def validate_triplets(
diff --git a/semantica/triplet_store/query_engine.py b/semantica/triplet_store/query_engine.py
index 49e5a589..2d9207d5 100644
--- a/semantica/triplet_store/query_engine.py
+++ b/semantica/triplet_store/query_engine.py
@@ -22,7 +22,7 @@ Main Classes:
Example Usage:
>>> from semantica.triplet_store import QueryEngine
>>> engine = QueryEngine(enable_caching=True, enable_optimization=True)
- >>> result = engine.execute_query(sparql_query, store_adapter)
+ >>> result = engine.execute_query(sparql_query, store_backend)
>>> plan = engine.plan_query(sparql_query)
>>> stats = engine.get_query_statistics()
@@ -96,13 +96,13 @@ class QueryEngine:
self.query_cache: Dict[str, QueryResult] = {}
self.query_history: List[Dict[str, Any]] = []
- def execute_query(self, query: str, store_adapter: Any, **options) -> QueryResult:
+ def execute_query(self, query: str, store_backend: Any, **options) -> QueryResult:
"""
Execute SPARQL query.
Args:
query: SPARQL query string
- store_adapter: Triplet store adapter instance
+ store_backend: Triplet store backend instance
**options: Additional options
Returns:
@@ -157,10 +157,10 @@ class QueryEngine:
self.progress_tracker.update_tracking(
tracking_id, message="Executing query on store..."
)
- if hasattr(store_adapter, "execute_sparql"):
- result_data = store_adapter.execute_sparql(optimized_query, **options)
+ if hasattr(store_backend, "execute_sparql"):
+ result_data = store_backend.execute_sparql(optimized_query, **options)
else:
- raise ProcessingError("Store adapter does not support SPARQL execution")
+ raise ProcessingError("Store backend does not support SPARQL execution")
execution_time = time.time() - start_time
diff --git a/semantica/triplet_store/rdf4j_adapter.py b/semantica/triplet_store/rdf4j_store.py
similarity index 90%
rename from semantica/triplet_store/rdf4j_adapter.py
rename to semantica/triplet_store/rdf4j_store.py
index 89027a80..ded790bb 100644
--- a/semantica/triplet_store/rdf4j_adapter.py
+++ b/semantica/triplet_store/rdf4j_store.py
@@ -1,5 +1,5 @@
"""
-RDF4J Adapter Module
+RDF4J Store Module
This module provides Eclipse RDF4J integration for RDF storage and SPARQL
querying, supporting repository management and transaction operations.
@@ -13,14 +13,14 @@ Key Features:
- Bulk operations
Main Classes:
- - RDF4JAdapter: Main RDF4J integration adapter
+ - RDF4JStore: Main RDF4J integration store
Example Usage:
- >>> from semantica.triplet_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_triplets(triplets)
+ >>> from semantica.triplet_store import RDF4JStore
+ >>> store = RDF4JStore(endpoint="http://localhost:8080/rdf4j-server", repository_id="repo1")
+ >>> result = store.execute_sparql(sparql_query)
+ >>> tx_id = store.begin_transaction()
+ >>> result = store.add_triplets(triplets)
Author: Semantica Contributors
License: MIT
@@ -36,31 +36,26 @@ from ..utils.logging import get_logger
from ..utils.progress_tracker import get_progress_tracker
-class RDF4JAdapter:
+class RDF4JStore:
"""
- Eclipse RDF4J adapter for triplet store operations.
+ Eclipse RDF4J store for triplet store operations.
- • RDF4J connection and repository management
- • SPARQL query execution
- • Repository configuration and setup
- • Transaction support
- • Performance optimization
- • Error handling and recovery
+ This class provides integration with Eclipse RDF4J, supporting
+ remote repositories, transactions, and high-performance querying.
"""
- def __init__(self, endpoint: str, **config):
+ def __init__(
+ self, endpoint: Optional[str] = None, repository_id: Optional[str] = None, **config
+ ):
"""
- Initialize RDF4J adapter.
+ Initialize RDF4J store.
Args:
- endpoint: RDF4J server endpoint
- **config: Additional configuration:
- - repository_id: Repository identifier
- - username: Username for authentication
- - password: Password for authentication
- - timeout: Request timeout (default: 30)
+ endpoint: RDF4J server URL
+ repository_id: Repository identifier
+ **config: Additional configuration options
"""
- self.logger = get_logger("rdf4j_adapter")
+ self.logger = get_logger("rdf4j_store")
self.config = config
self.progress_tracker = get_progress_tracker()
@@ -185,7 +180,7 @@ class RDF4JAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="triplet_store",
- submodule="RDF4JAdapter",
+ submodule="RDF4JStore",
message="Executing SPARQL query on RDF4J",
)
@@ -251,7 +246,7 @@ class RDF4JAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="triplet_store",
- submodule="RDF4JAdapter",
+ submodule="RDF4JStore",
message=f"Adding {len(triplets)} triplets to RDF4J repository",
)
diff --git a/semantica/triplet_store/triplet_manager.py b/semantica/triplet_store/triplet_manager.py
index be3b076b..2d686643 100644
--- a/semantica/triplet_store/triplet_manager.py
+++ b/semantica/triplet_store/triplet_manager.py
@@ -10,7 +10,7 @@ Key Features:
- Multi-store management and registration
- Batch operations and bulk loading
- Triplet validation and consistency
- - Store adapter pattern
+ - Store backend pattern
- Error handling and recovery
Main Classes:
@@ -126,10 +126,10 @@ class TripletManager:
if not self._validate_triplet(triplet):
raise ValidationError("Invalid triplet")
- # Add to store (delegates to adapter)
+ # Add to store (delegates to backend)
try:
- adapter = self._get_adapter(store)
- result = adapter.add_triplet(triplet, **options)
+ store_backend = self._get_store_backend(store)
+ result = store_backend.add_triplet(triplet, **options)
return {
"success": True,
@@ -179,7 +179,7 @@ class TripletManager:
valid_triplets = triplets
# Add to store
- adapter = self._get_adapter(store)
+ store_backend = self._get_store_backend(store)
batch_size = options.get("batch_size", 1000)
total_batches = (len(valid_triplets) + batch_size - 1) // batch_size
@@ -191,7 +191,7 @@ class TripletManager:
message=f"Processing batch {batch_num}/{total_batches}...",
)
batch = valid_triplets[i : i + batch_size]
- result = adapter.add_triplets(batch, **options)
+ result = store_backend.add_triplets(batch, **options)
results.append(result)
self.progress_tracker.stop_tracking(
@@ -237,8 +237,8 @@ class TripletManager:
store = self._get_store(store_id)
try:
- adapter = self._get_adapter(store)
- return adapter.get_triplets(subject, predicate, object, **options)
+ store_backend = self._get_store_backend(store)
+ return store_backend.get_triplets(subject, predicate, object, **options)
except Exception as e:
self.logger.error(f"Failed to get triplets: {e}")
raise ProcessingError(f"Failed to get triplets: {e}")
@@ -260,8 +260,8 @@ class TripletManager:
store = self._get_store(store_id)
try:
- adapter = self._get_adapter(store)
- result = adapter.delete_triplet(triplet, **options)
+ store_backend = self._get_store_backend(store)
+ result = store_backend.delete_triplet(triplet, **options)
return {"success": True, "store_id": store.store_id, **result}
except Exception as e:
@@ -313,26 +313,26 @@ class TripletManager:
return self.stores[store_id]
- def _get_adapter(self, store: TripletStore) -> Any:
- """Get adapter for store type."""
+ def _get_store_backend(self, store: TripletStore) -> Any:
+ """Get backend store for store type."""
store_type = store.store_type.lower()
if store_type == "blazegraph":
- from .blazegraph_adapter import BlazegraphAdapter
+ from .blazegraph_store import BlazegraphStore
- return BlazegraphAdapter(endpoint=store.endpoint, **store.config)
+ return BlazegraphStore(endpoint=store.endpoint, **store.config)
elif store_type == "jena":
- from .jena_adapter import JenaAdapter
+ from .jena_store import JenaStore
- return JenaAdapter(**store.config)
+ return JenaStore(**store.config)
elif store_type == "rdf4j":
- from .rdf4j_adapter import RDF4JAdapter
+ from .rdf4j_store import RDF4JStore
- return RDF4JAdapter(endpoint=store.endpoint, **store.config)
+ return RDF4JStore(endpoint=store.endpoint, **store.config)
elif store_type == "virtuoso":
- from .virtuoso_adapter import VirtuosoAdapter
+ from .virtuoso_store import VirtuosoStore
- return VirtuosoAdapter(endpoint=store.endpoint, **store.config)
+ return VirtuosoStore(endpoint=store.endpoint, **store.config)
else:
raise ValidationError(f"Unsupported store type: {store_type}")
diff --git a/semantica/triplet_store/triplet_store_usage.md b/semantica/triplet_store/triplet_store_usage.md
index 89a557af..12b8a83f 100644
--- a/semantica/triplet_store/triplet_store_usage.md
+++ b/semantica/triplet_store/triplet_store_usage.md
@@ -10,7 +10,7 @@ This comprehensive guide demonstrates how to use the triplet store module for RD
4. [SPARQL Query Execution](#sparql-query-execution)
5. [Query Optimization](#query-optimization)
6. [Bulk Loading](#bulk-loading)
-7. [Store Adapters](#store-adapters)
+7. [Store Backends](#store-backends)
8. [Algorithms and Methods](#algorithms-and-methods)
9. [Configuration](#configuration)
10. [Advanced Examples](#advanced-examples)
@@ -66,17 +66,17 @@ print(f"Found {len(triplets)} triplets")
### Using QueryEngine
```python
-from semantica.triplet_store import QueryEngine, BlazegraphAdapter
+from semantica.triplet_store import QueryEngine, BlazegraphStore
# Create query engine
engine = QueryEngine(enable_caching=True, enable_optimization=True)
-# Create adapter
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+# Create store
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Execute query
query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10"
-result = engine.execute_query(query, adapter)
+result = engine.execute_query(query, store)
print(f"Found {len(result.bindings)} results")
print(f"Execution time: {result.execution_time:.2f}s")
@@ -270,13 +270,13 @@ print(f"Updated: {result['success']}")
### Basic Query Execution
```python
-from semantica.triplet_store import QueryEngine, BlazegraphAdapter
+from semantica.triplet_store import QueryEngine, BlazegraphStore
# Create query engine
engine = QueryEngine(enable_caching=True)
-# Create adapter
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+# Create store
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Execute SELECT query
query = """
@@ -287,7 +287,7 @@ WHERE {
}
LIMIT 10
"""
-result = engine.execute_query(query, adapter)
+result = engine.execute_query(query, store)
print(f"Variables: {result.variables}")
print(f"Results: {len(result.bindings)}")
@@ -298,12 +298,12 @@ for binding in result.bindings[:5]:
### Using Convenience Function
```python
-from semantica.triplet_store import execute_query, BlazegraphAdapter
+from semantica.triplet_store import execute_query, BlazegraphStore
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10"
-result = execute_query(query, adapter, method="default")
+result = execute_query(query, store, method="default")
print(f"Found {len(result.bindings)} results")
```
@@ -311,13 +311,13 @@ print(f"Found {len(result.bindings)} results")
### Query Result Processing
```python
-from semantica.triplet_store import QueryEngine, BlazegraphAdapter
+from semantica.triplet_store import QueryEngine, BlazegraphStore
engine = QueryEngine()
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
query = "SELECT ?name ?age WHERE { ?s ?name . ?s ?age }"
-result = engine.execute_query(query, adapter)
+result = engine.execute_query(query, store)
# Process results
for binding in result.bindings:
@@ -332,20 +332,20 @@ print(f"Metadata: {result.metadata}")
### Query Caching
```python
-from semantica.triplet_store import QueryEngine, BlazegraphAdapter
+from semantica.triplet_store import QueryEngine, BlazegraphStore
# Enable caching
engine = QueryEngine(enable_caching=True, cache_size=1000)
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10"
# First execution (not cached)
-result1 = engine.execute_query(query, adapter)
+result1 = engine.execute_query(query, store)
print(f"First execution: {result1.execution_time:.2f}s, Cached: {result1.metadata.get('cached', False)}")
# Second execution (cached)
-result2 = engine.execute_query(query, adapter)
+result2 = engine.execute_query(query, store)
print(f"Second execution: {result2.execution_time:.2f}s, Cached: {result2.metadata.get('cached', False)}")
# Clear cache
@@ -403,15 +403,15 @@ print(f"Execution steps: {plan.execution_steps}")
### Query Statistics
```python
-from semantica.triplet_store import QueryEngine, BlazegraphAdapter
+from semantica.triplet_store import QueryEngine, BlazegraphStore
engine = QueryEngine(enable_caching=True)
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Execute multiple queries
for i in range(10):
query = f"SELECT ?s ?p ?o WHERE {{ ?s ?p ?o }} LIMIT {i * 10}"
- engine.execute_query(query, adapter)
+ engine.execute_query(query, store)
# Get statistics
stats = engine.get_query_statistics()
@@ -427,14 +427,14 @@ print(f"Cache size: {stats['cache_size']}")
### Basic Bulk Loading
```python
-from semantica.triplet_store import BulkLoader, BlazegraphAdapter
+from semantica.triplet_store import BulkLoader, BlazegraphStore
from semantica.semantic_extract.triplet_extractor import Triplet
# Create bulk loader
loader = BulkLoader(batch_size=1000, max_retries=3)
-# Create adapter
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+# Create store
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Generate triplets
triplets = [
@@ -443,7 +443,7 @@ triplets = [
]
# Load triplets
-progress = loader.load_triplets(triplets, adapter)
+progress = loader.load_triplets(triplets, store)
print(f"Loaded: {progress.loaded_triplets}/{progress.total_triplets}")
print(f"Failed: {progress.failed_triplets}")
@@ -455,11 +455,11 @@ print(f"Throughput: {progress.metadata.get('throughput', 0):.0f} triplets/sec")
### Progress Tracking
```python
-from semantica.triplet_store import BulkLoader, BlazegraphAdapter, LoadProgress
+from semantica.triplet_store import BulkLoader, BlazegraphStore, LoadProgress
from semantica.semantic_extract.triplet_extractor import Triplet
loader = BulkLoader(batch_size=1000)
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Progress callback
def progress_callback(progress: LoadProgress):
@@ -470,7 +470,7 @@ def progress_callback(progress: LoadProgress):
# Load with progress callback
triplets = [Triplet(f"http://example.org/entity{i}", "http://example.org/hasName", f"Entity {i}")
for i in range(5000)]
-progress = loader.load_triplets(triplets, adapter, progress_callback=progress_callback)
+progress = loader.load_triplets(triplets, store, progress_callback=progress_callback)
```
### Pre-load Validation
@@ -501,11 +501,11 @@ print(f"Valid triplets: {validation['valid_triplets']}/{validation['total_triple
### Stream-based Loading
```python
-from semantica.triplet_store import BulkLoader, BlazegraphAdapter
+from semantica.triplet_store import BulkLoader, BlazegraphStore
from semantica.semantic_extract.triplet_extractor import Triplet
loader = BulkLoader(batch_size=1000)
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+store = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Create stream of triplets
def triplet_stream():
@@ -513,20 +513,20 @@ def triplet_stream():
yield Triplet(f"http://example.org/entity{i}", "http://example.org/hasName", f"Entity {i}")
# Load from stream
-progress = loader.load_from_stream(triplet_stream(), adapter)
+progress = loader.load_from_stream(triplet_stream(), store)
print(f"Loaded {progress.loaded_triplets} triplets from stream")
```
-## Store Adapters
+## Store Backends
-### Blazegraph Adapter
+### Blazegraph Store
```python
-from semantica.triplet_store import BlazegraphAdapter
+from semantica.triplet_store import BlazegraphStore
from semantica.semantic_extract.triplet_extractor import Triplet
-# Create Blazegraph adapter
-adapter = BlazegraphAdapter(
+# Create Blazegraph store
+store = BlazegraphStore(
endpoint="http://localhost:9999/blazegraph",
namespace="kb",
auth=("user", "password") # Optional
@@ -536,26 +536,26 @@ adapter = BlazegraphAdapter(
triplets = [
Triplet("http://example.org/entity1", "http://example.org/hasName", "John")
]
-result = adapter.add_triplets(triplets)
+result = store.add_triplets(triplets)
print(f"Added: {result['success']}")
# Execute SPARQL query
query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10"
-result = adapter.execute_sparql(query)
+result = store.execute_sparql(query)
print(f"Found {len(result['bindings'])} results")
```
-### Jena Adapter
+### Jena Store
```python
-from semantica.triplet_store import JenaAdapter
+from semantica.triplet_store import JenaStore
from semantica.semantic_extract.triplet_extractor import Triplet
-# Create Jena adapter (in-memory)
-adapter = JenaAdapter()
+# Create Jena store (in-memory)
+store = JenaStore()
# Or connect to Fuseki endpoint
-adapter = JenaAdapter(
+store = JenaStore(
endpoint="http://localhost:3030/ds",
dataset="default",
enable_inference=True
@@ -565,21 +565,21 @@ adapter = JenaAdapter(
triplets = [
Triplet("http://example.org/entity1", "http://example.org/hasName", "John")
]
-result = adapter.add_triplets(triplets)
+result = store.add_triplets(triplets)
# Serialize to Turtle
-turtle = adapter.serialize(format="turtle")
+turtle = store.serialize(format="turtle")
print(turtle)
```
-### RDF4J Adapter
+### RDF4J Store
```python
-from semantica.triplet_store import RDF4JAdapter
+from semantica.triplet_store import RDF4JStore
from semantica.semantic_extract.triplet_extractor import Triplet
-# Create RDF4J adapter
-adapter = RDF4JAdapter(
+# Create RDF4J store
+store = RDF4JStore(
endpoint="http://localhost:8080/rdf4j-server",
repository="test"
)
@@ -588,17 +588,17 @@ adapter = RDF4JAdapter(
triplets = [
Triplet("http://example.org/entity1", "http://example.org/hasName", "John")
]
-result = adapter.add_triplets(triplets)
+result = store.add_triplets(triplets)
```
-### Virtuoso Adapter
+### Virtuoso Store
```python
-from semantica.triplet_store import VirtuosoAdapter
+from semantica.triplet_store import VirtuosoStore
from semantica.semantic_extract.triplet_extractor import Triplet
-# Create Virtuoso adapter
-adapter = VirtuosoAdapter(
+# Create Virtuoso store
+store = VirtuosoStore(
endpoint="http://localhost:8890/sparql",
user="dba",
password="dba"
@@ -608,19 +608,19 @@ adapter = VirtuosoAdapter(
triplets = [
Triplet("http://example.org/entity1", "http://example.org/hasName", "John")
]
-result = adapter.add_triplets(triplets)
+result = store.add_triplets(triplets)
```
## Algorithms and Methods
-### Triplet Store Management Algorithms
+### Store Backends
#### Store Registration
-**Algorithm**: Store type detection and adapter factory pattern
+**Algorithm**: Store type detection and store factory pattern
1. **Store Type Detection**: Identify backend type (blazegraph, jena, rdf4j, virtuoso)
2. **Configuration Storage**: Store store configuration (endpoint, namespace, etc.)
-3. **Adapter Factory**: Create appropriate adapter instance based on store type
+3. **Store Factory**: Create appropriate store instance based on store type
4. **Default Store Selection**: Set first registered store as default if none specified
**Time Complexity**: O(1) for registration
@@ -631,16 +631,16 @@ result = adapter.add_triplets(triplets)
store = manager.register_store("main", "blazegraph", "http://localhost:9999/blazegraph")
```
-#### Adapter Pattern
+#### Backend Pattern
**Algorithm**: Unified interface for multiple backends
-1. **Interface Definition**: Common interface for all adapters (add_triplet, execute_sparql, etc.)
-2. **Backend-Specific Implementation**: Each adapter implements interface for its backend
-3. **Adapter Instantiation**: Create adapter instance on-demand
-4. **Operation Delegation**: Delegate operations to appropriate adapter
+1. **Interface Definition**: Common interface for all stores (add_triplet, execute_sparql, etc.)
+2. **Backend-Specific Implementation**: Each store implements interface for its backend
+3. **Store Instantiation**: Create store instance on-demand
+4. **Operation Delegation**: Delegate operations to appropriate store
-**Time Complexity**: O(1) for adapter creation
-**Space Complexity**: O(1) per adapter
+**Time Complexity**: O(1) for store creation
+**Space Complexity**: O(1) per store
### CRUD Operations Algorithms
@@ -648,8 +648,8 @@ store = manager.register_store("main", "blazegraph", "http://localhost:9999/blaz
**Algorithm**: Single and batch triplet insertion
1. **Triplet Validation**: Check required fields (subject, predicate, object), validate confidence (0-1)
-2. **Adapter Selection**: Get adapter for specified store
-3. **Operation Delegation**: Delegate to adapter's add_triplet/add_triplets method
+2. **Store Selection**: Get store for specified store
+3. **Operation Delegation**: Delegate to store's add_triplet/add_triplets method
4. **Result Processing**: Process and return operation result
**Time Complexity**: O(1) for single, O(n) for batch where n = triplets
@@ -665,7 +665,7 @@ result = manager.add_triplets(triplets, store_id="main", batch_size=1000)
**Algorithm**: Pattern-based triplet retrieval
1. **Pattern Construction**: Build SPARQL query from subject/predicate/object patterns
-2. **Query Execution**: Execute SPARQL query via adapter
+2. **Query Execution**: Execute SPARQL query via store
3. **Result Binding Extraction**: Extract bindings from query result
4. **Triplet Reconstruction**: Convert bindings to Triplet objects
@@ -692,7 +692,7 @@ triplets = manager.get_triplets(subject="http://example.org/entity1", store_id="
```python
# Batch processing
-progress = loader.load_triplets(triplets, adapter, batch_size=1000)
+progress = loader.load_triplets(triplets, store, batch_size=1000)
```
#### Progress Tracking
@@ -796,7 +796,7 @@ cost = engine._estimate_query_cost(query)
#### QueryEngine Methods
-- `execute_query(query, store_adapter, **options)`: Execute SPARQL query
+- `execute_query(query, store_backend, **options)`: Execute SPARQL query
- `optimize_query(query, **options)`: Optimize SPARQL query
- `plan_query(query, **options)`: Create query execution plan
- `clear_cache()`: Clear query cache
@@ -804,9 +804,9 @@ cost = engine._estimate_query_cost(query)
#### BulkLoader Methods
-- `load_triples(triples, store_adapter, **options)`: Load triplets in bulk
-- `load_from_file(file_path, store_adapter, **options)`: Load triplets from file
-- `load_from_stream(triples_stream, store_adapter, **options)`: Load triplets from stream
+- `load_triples(triples, store_backend, **options)`: Load triplets in bulk
+- `load_from_file(file_path, store_backend, **options)`: Load triplets from file
+- `load_from_stream(triples_stream, store_backend, **options)`: Load triplets from stream
- `validate_before_load(triples, **options)`: Validate triplets before loading
#### Convenience Functions
@@ -817,9 +817,9 @@ cost = engine._estimate_query_cost(query)
- `get_triples(subject, predicate, object, store_id, method, **options)`: Get triplets wrapper
- `delete_triplet(triple, store_id, method, **options)`: Delete triplet wrapper
- `update_triplet(old_triple, new_triple, store_id, method, **options)`: Update triplet wrapper
-- `execute_query(query, store_adapter, method, **options)`: Execute query wrapper
+- `execute_query(query, store_backend, method, **options)`: Execute query wrapper
- `optimize_query(query, method, **options)`: Optimize query wrapper
-- `bulk_load(triples, store_adapter, method, **options)`: Bulk load wrapper
+- `bulk_load(triples, store_backend, method, **options)`: Bulk load wrapper
- `validate_triples(triples, method, **options)`: Validate triplets wrapper
## Dataclasses
@@ -980,8 +980,8 @@ triplets = [
result = add_triples(triples, store_id="main", batch_size=100)
# 3. Execute queries
-from semantica.triplet_store import BlazegraphAdapter
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+from semantica.triplet_store import BlazegraphStore
+adapter = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10"
query_result = execute_query(query, adapter)
@@ -1012,10 +1012,10 @@ manager.add_triplet(triple, store_id="backup")
### Query Optimization Workflow
```python
-from semantica.triplet_store import QueryEngine, BlazegraphAdapter
+from semantica.triplet_store import QueryEngine, BlazegraphStore
engine = QueryEngine(enable_optimization=True, enable_caching=True)
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+adapter = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Original query
query = """
@@ -1040,11 +1040,11 @@ print(f"Optimized: {result.metadata.get('optimized', False)}")
### Bulk Loading with Validation
```python
-from semantica.triplet_store import BulkLoader, BlazegraphAdapter
+from semantica.triplet_store import BulkLoader, BlazegraphStore
from semantica.semantic_extract.triplet_extractor import Triplet
loader = BulkLoader(batch_size=1000, max_retries=3)
-adapter = BlazegraphAdapter(endpoint="http://localhost:9999/blazegraph")
+adapter = BlazegraphStore(endpoint="http://localhost:9999/blazegraph")
# Generate triples
triplets = [
diff --git a/semantica/triplet_store/virtuoso_adapter.py b/semantica/triplet_store/virtuoso_store.py
similarity index 89%
rename from semantica/triplet_store/virtuoso_adapter.py
rename to semantica/triplet_store/virtuoso_store.py
index 145ff8ba..f6d33f01 100644
--- a/semantica/triplet_store/virtuoso_adapter.py
+++ b/semantica/triplet_store/virtuoso_store.py
@@ -1,5 +1,5 @@
"""
-Virtuoso Adapter Module
+Virtuoso Store Module
This module provides Virtuoso RDF store integration for RDF storage and
SPARQL querying, supporting cluster connections and query optimization.
@@ -13,14 +13,14 @@ Key Features:
- Query optimization
Main Classes:
- - VirtuosoAdapter: Main Virtuoso integration adapter
+ - VirtuosoStore: Main Virtuoso integration store
Example Usage:
- >>> from semantica.triplet_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(triplets, graph="http://example.org/graph")
- >>> cluster_status = adapter.connect_cluster(cluster_config)
+ >>> from semantica.triplet_store import VirtuosoStore
+ >>> store = VirtuosoStore(endpoint="http://localhost:8890/sparql", username="dba", password="dba")
+ >>> result = store.execute_sparql(sparql_query)
+ >>> load_result = store.bulk_load(triplets, graph="http://example.org/graph")
+ >>> cluster_status = store.connect_cluster(cluster_config)
Author: Semantica Contributors
License: MIT
@@ -37,31 +37,23 @@ from ..utils.logging import get_logger
from ..utils.progress_tracker import get_progress_tracker
-class VirtuosoAdapter:
+class VirtuosoStore:
"""
- Virtuoso RDF store adapter.
+ Virtuoso RDF store backend.
- • Virtuoso connection and authentication
- • SPARQL query execution
- • Bulk data loading and management
- • Graph and namespace management
- • Performance optimization
- • Error handling and recovery
+ This class provides integration with OpenLink Virtuoso, supporting
+ SPARQL queries, bulk loading, and cluster management.
"""
- def __init__(self, endpoint: str, **config):
+ def __init__(self, endpoint: Optional[str] = None, **config):
"""
- Initialize Virtuoso adapter.
+ Initialize Virtuoso store.
Args:
- endpoint: Virtuoso endpoint URL
- **config: Additional configuration:
- - username: Username for authentication
- - password: Password for authentication
- - timeout: Request timeout (default: 30)
- - graph: Default graph URI
+ endpoint: SPARQL endpoint URL (e.g., http://localhost:8890/sparql)
+ **config: Additional configuration options
"""
- self.logger = get_logger("virtuoso_adapter")
+ self.logger = get_logger("virtuoso_store")
self.config = config
self.progress_tracker = get_progress_tracker()
@@ -124,8 +116,8 @@ class VirtuosoAdapter:
connections = []
for endpoint in endpoints:
try:
- adapter = VirtuosoAdapter(endpoint, **cluster_config)
- if adapter.connected:
+ store = VirtuosoStore(endpoint, **cluster_config)
+ if store.connected:
connections.append(endpoint)
except Exception as e:
self.logger.warning(f"Failed to connect to {endpoint}: {e}")
@@ -149,7 +141,7 @@ class VirtuosoAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="triplet_store",
- submodule="VirtuosoAdapter",
+ submodule="VirtuosoStore",
message="Executing SPARQL query on Virtuoso",
)
@@ -242,7 +234,7 @@ class VirtuosoAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="triplet_store",
- submodule="VirtuosoAdapter",
+ submodule="VirtuosoStore",
message=f"Bulk loading {len(triplets)} triplets to Virtuoso",
)
diff --git a/semantica/vector_store/__init__.py b/semantica/vector_store/__init__.py
index 0a039933..825aec35 100644
--- a/semantica/vector_store/__init__.py
+++ b/semantica/vector_store/__init__.py
@@ -48,11 +48,11 @@ Namespace Management:
- Access Control: Permission-based access (read, write, delete permissions), entity-to-permission mapping (user/role to permissions), permission checking, access control enforcement
- Namespace Operations: Namespace creation, namespace deletion, vector addition/removal, namespace metadata management, namespace statistics collection
-Adapter Pattern:
- - FAISS Adapter: Local vector storage, FAISS index management, index persistence (save/load), batch operations, multiple index types support
- - Weaviate Adapter: Schema-aware storage, GraphQL query support, object-oriented data model, batch operations, schema management
- - Qdrant Adapter: Point-based storage, payload filtering, collection management, optimized search, batch operations
- - Milvus Adapter: Scalable vector database, collection management, partitioning, complex querying, index building
+Backend Pattern:
+ - FAISS Store: Local vector storage, FAISS index management, index persistence (save/load), batch operations, multiple index types support
+ - Weaviate Store: Schema-aware storage, GraphQL query support, object-oriented data model, batch operations, schema management
+ - Qdrant Store: Point-based storage, payload filtering, collection management, optimized search, batch operations
+ - Milvus Store: Scalable vector database, collection management, partitioning, complex querying, index building
Supported Backends:
- FAISS: In-memory/local disk (Facebook AI Similarity Search)
@@ -88,10 +88,10 @@ Main Classes:
- VectorIndexer: Vector indexing engine
- VectorRetriever: Vector retrieval and similarity search
- VectorManager: Vector store management and operations
- - FAISSAdapter: FAISS integration for local vector storage
- - WeaviateAdapter: Weaviate vector database integration
- - QdrantAdapter: Qdrant vector database integration
- - MilvusAdapter: Milvus vector database integration
+ - FAISSStore: FAISS integration for local vector storage
+ - WeaviateStore: Weaviate vector database integration
+ - QdrantStore: Qdrant vector database integration
+ - MilvusStore: Milvus vector database integration
- HybridSearch: Hybrid vector and metadata search
- MetadataStore: Metadata indexing and management
- NamespaceManager: Namespace isolation and management
@@ -128,7 +128,7 @@ License: MIT
"""
from .config import VectorStoreConfig, vector_store_config
-from .faiss_adapter import FAISSAdapter, FAISSIndex, FAISSIndexBuilder, FAISSSearch
+from .faiss_store import FAISSStore, FAISSIndex, FAISSIndexBuilder, FAISSSearch
from .hybrid_search import HybridSearch, MetadataFilter, SearchRanker
from .metadata_store import MetadataIndex, MetadataSchema, MetadataStore
from .methods import (
@@ -143,13 +143,13 @@ from .methods import (
store_vectors,
update_vectors,
)
-from .milvus_adapter import MilvusAdapter, MilvusClient, MilvusCollection, MilvusSearch
+from .milvus_store import MilvusStore, MilvusClient, MilvusCollection, MilvusSearch
from .namespace_manager import Namespace, NamespaceManager
-from .qdrant_adapter import QdrantAdapter, QdrantClient, QdrantCollection, QdrantSearch
+from .qdrant_store import QdrantStore, QdrantClient, QdrantCollection, QdrantSearch
from .registry import MethodRegistry, method_registry
from .vector_store import VectorIndexer, VectorManager, VectorRetriever, VectorStore
-from .weaviate_adapter import (
- WeaviateAdapter,
+from .weaviate_store import (
+ WeaviateStore,
WeaviateClient,
WeaviateQuery,
WeaviateSchema,
@@ -162,22 +162,22 @@ __all__ = [
"VectorRetriever",
"VectorManager",
# FAISS
- "FAISSAdapter",
+ "FAISSStore",
"FAISSIndex",
"FAISSSearch",
"FAISSIndexBuilder",
# Weaviate
- "WeaviateAdapter",
+ "WeaviateStore",
"WeaviateClient",
"WeaviateSchema",
"WeaviateQuery",
# Qdrant
- "QdrantAdapter",
+ "QdrantStore",
"QdrantClient",
"QdrantCollection",
"QdrantSearch",
# Milvus
- "MilvusAdapter",
+ "MilvusStore",
"MilvusClient",
"MilvusCollection",
"MilvusSearch",
diff --git a/semantica/vector_store/faiss_adapter.py b/semantica/vector_store/faiss_store.py
similarity index 95%
rename from semantica/vector_store/faiss_adapter.py
rename to semantica/vector_store/faiss_store.py
index 2209e8b8..bfaf41d6 100644
--- a/semantica/vector_store/faiss_adapter.py
+++ b/semantica/vector_store/faiss_store.py
@@ -1,5 +1,5 @@
"""
-FAISS Adapter Module
+FAISS Store Module
This module provides FAISS (Facebook AI Similarity Search) integration for vector
storage and similarity search in the Semantica framework, supporting various index
@@ -14,18 +14,18 @@ Key Features:
- Optional dependency handling
Main Classes:
- - FAISSAdapter: Main FAISS adapter for vector operations
+ - FAISSStore: Main FAISS store for vector operations
- FAISSIndex: FAISS index wrapper with metadata support
- FAISSSearch: FAISS search operations
- FAISSIndexBuilder: FAISS index construction and configuration
Example Usage:
- >>> from semantica.vector_store import FAISSAdapter
- >>> adapter = FAISSAdapter(dimension=768)
- >>> index = adapter.create_index(index_type="flat", metric="L2")
- >>> vector_ids = adapter.add_vectors(vectors, ids, metadata)
- >>> results = adapter.search_similar(query_vector, k=10)
- >>> adapter.save_index("index.faiss")
+ >>> from semantica.vector_store import FAISSStore
+ >>> store = FAISSStore(dimension=768)
+ >>> index = store.create_index(index_type="flat", metric="L2")
+ >>> vector_ids = store.add_vectors(vectors, ids, metadata)
+ >>> results = store.search_similar(query_vector, k=10)
+ >>> store.save_index("index.faiss")
>>>
>>> from semantica.vector_store import FAISSIndexBuilder
>>> builder = FAISSIndexBuilder(dimension=768)
@@ -210,9 +210,9 @@ class FAISSIndexBuilder:
index.index.train(training_vectors.astype(np.float32))
-class FAISSAdapter:
+class FAISSStore:
"""
- FAISS adapter for vector storage and similarity search.
+ FAISS store for vector storage and similarity search.
• FAISS index creation and management
• Vector storage and retrieval
@@ -223,8 +223,8 @@ class FAISSAdapter:
"""
def __init__(self, dimension: int = 768, **config):
- """Initialize FAISS adapter."""
- self.logger = get_logger("faiss_adapter")
+ """Initialize FAISS store."""
+ self.logger = get_logger("faiss_store")
self.config = config
self.progress_tracker = get_progress_tracker()
self.dimension = dimension
@@ -281,7 +281,7 @@ class FAISSAdapter:
num_vectors = len(vectors) if isinstance(vectors, (list, np.ndarray)) else 1
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="FAISSAdapter",
+ submodule="FAISSStore",
message=f"Adding {num_vectors} vectors to FAISS index",
)
@@ -350,7 +350,7 @@ class FAISSAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="FAISSAdapter",
+ submodule="FAISSStore",
message=f"Searching for {k} similar vectors",
)
diff --git a/semantica/vector_store/milvus_adapter.py b/semantica/vector_store/milvus_store.py
similarity index 95%
rename from semantica/vector_store/milvus_adapter.py
rename to semantica/vector_store/milvus_store.py
index 839c3212..e250e3d9 100644
--- a/semantica/vector_store/milvus_adapter.py
+++ b/semantica/vector_store/milvus_store.py
@@ -1,5 +1,5 @@
"""
-Milvus Adapter Module
+Milvus Store Module
This module provides Milvus vector database integration for vector storage and
similarity search in the Semantica framework, supporting collection management,
@@ -16,20 +16,20 @@ Key Features:
- Optional dependency handling
Main Classes:
- - MilvusAdapter: Main Milvus adapter for vector operations
+ - MilvusStore: Main Milvus store for vector operations
- MilvusClient: Milvus client wrapper
- MilvusCollection: Collection wrapper with operations
- MilvusSearch: Search operations and filtering
Example Usage:
- >>> from semantica.vector_store import MilvusAdapter
- >>> adapter = MilvusAdapter(host="localhost", port=19530)
- >>> adapter.connect()
- >>> collection = adapter.create_collection("my-collection", dimension=768, metric_type="L2")
- >>> adapter.insert_vectors(vectors)
+ >>> from semantica.vector_store import MilvusStore
+ >>> store = MilvusStore(host="localhost", port=19530)
+ >>> store.connect()
+ >>> collection = store.create_collection("my-collection", dimension=768, metric_type="L2")
+ >>> store.insert_vectors(vectors)
>>> collection.load()
- >>> results = adapter.search_vectors(query_vector, limit=10, expr="category == 'science'")
- >>> stats = adapter.get_stats()
+ >>> results = store.search_vectors(query_vector, limit=10, expr="category == 'science'")
+ >>> stats = store.get_stats()
Author: Semantica Contributors
License: MIT
@@ -240,9 +240,9 @@ class MilvusSearch:
)
-class MilvusAdapter:
+class MilvusStore:
"""
- Milvus adapter for vector storage and similarity search.
+ Milvus store for vector storage and similarity search.
• Milvus connection and authentication
• Collection and partition management
@@ -260,8 +260,8 @@ class MilvusAdapter:
password: Optional[str] = None,
**config,
):
- """Initialize Milvus adapter."""
- self.logger = get_logger("milvus_adapter")
+ """Initialize Milvus store."""
+ self.logger = get_logger("milvus_store")
self.config = config
self.progress_tracker = get_progress_tracker()
self.host = host or config.get("host", "localhost")
@@ -410,7 +410,7 @@ class MilvusAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="MilvusAdapter",
+ submodule="MilvusStore",
message=f"Inserting {len(vectors)} vectors into Milvus collection",
)
@@ -481,7 +481,7 @@ class MilvusAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="MilvusAdapter",
+ submodule="MilvusStore",
message=f"Searching for {limit} similar vectors in Milvus",
)
diff --git a/semantica/vector_store/qdrant_adapter.py b/semantica/vector_store/qdrant_store.py
similarity index 95%
rename from semantica/vector_store/qdrant_adapter.py
rename to semantica/vector_store/qdrant_store.py
index 56699de4..c0f07745 100644
--- a/semantica/vector_store/qdrant_adapter.py
+++ b/semantica/vector_store/qdrant_store.py
@@ -1,5 +1,5 @@
"""
-Qdrant Adapter Module
+Qdrant Store Module
This module provides Qdrant vector database integration for vector storage and
similarity search in the Semantica framework, supporting collection management,
@@ -15,19 +15,19 @@ Key Features:
- Optional dependency handling
Main Classes:
- - QdrantAdapter: Main Qdrant adapter for vector operations
+ - QdrantStore: Main Qdrant store for vector operations
- QdrantClient: Qdrant client wrapper
- QdrantCollection: Collection wrapper with operations
- QdrantSearch: Search operations and filtering
Example Usage:
- >>> from semantica.vector_store import QdrantAdapter
- >>> adapter = QdrantAdapter(url="http://localhost:6333")
- >>> adapter.connect()
- >>> collection = adapter.create_collection("my-collection", vector_size=768, distance="Cosine")
- >>> adapter.insert_vectors(vectors, ids, payloads=metadata)
- >>> results = adapter.search_vectors(query_vector, limit=10, filter={"category": "science"})
- >>> stats = adapter.get_stats()
+ >>> from semantica.vector_store import QdrantStore
+ >>> store = QdrantStore(url="http://localhost:6333")
+ >>> store.connect()
+ >>> collection = store.create_collection("my-collection", vector_size=768, distance="Cosine")
+ >>> store.insert_vectors(vectors, ids, payloads=metadata)
+ >>> results = store.search_vectors(query_vector, limit=10, filter={"category": "science"})
+ >>> stats = store.get_stats()
Author: Semantica Contributors
License: MIT
@@ -234,9 +234,9 @@ class QdrantSearch:
)
-class QdrantAdapter:
+class QdrantStore:
"""
- Qdrant adapter for vector storage and similarity search.
+ Qdrant store for vector storage and similarity search.
• Qdrant connection and authentication
• Collection and point management
@@ -249,8 +249,8 @@ class QdrantAdapter:
def __init__(
self, url: Optional[str] = None, api_key: Optional[str] = None, **config
):
- """Initialize Qdrant adapter."""
- self.logger = get_logger("qdrant_adapter")
+ """Initialize Qdrant store."""
+ self.logger = get_logger("qdrant_store")
self.config = config
self.progress_tracker = get_progress_tracker()
self.url = url or config.get("url", "http://localhost:6333")
@@ -386,7 +386,7 @@ class QdrantAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="QdrantAdapter",
+ submodule="QdrantStore",
message=f"Inserting {len(vectors)} vectors into Qdrant collection",
)
@@ -456,7 +456,7 @@ class QdrantAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="QdrantAdapter",
+ submodule="QdrantStore",
message=f"Searching for {limit} similar vectors in Qdrant",
)
diff --git a/semantica/vector_store/vector_store.py b/semantica/vector_store/vector_store.py
index d3789f6b..81359eb6 100644
--- a/semantica/vector_store/vector_store.py
+++ b/semantica/vector_store/vector_store.py
@@ -11,7 +11,7 @@ Key Features:
- Vector indexing and optimization
- Metadata association with vectors
- Vector update and deletion operations
- - Multi-backend support through adapters
+ - Multi-backend support through stores
Main Classes:
- VectorStore: Main vector store interface for storing and searching vectors
diff --git a/semantica/vector_store/vector_store_usage.md b/semantica/vector_store/vector_store_usage.md
index d9248dc1..9680ac26 100644
--- a/semantica/vector_store/vector_store_usage.md
+++ b/semantica/vector_store/vector_store_usage.md
@@ -11,7 +11,7 @@ This comprehensive guide demonstrates how to use the vector store module for vec
5. [Hybrid Search](#hybrid-search)
6. [Metadata Management](#metadata-management)
7. [Namespace Management](#namespace-management)
-8. [Store Adapters](#store-adapters)
+8. [Store Backends](#store-adapters)
9. [Algorithms and Methods](#algorithms-and-methods)
10. [Configuration](#configuration)
11. [Advanced Examples](#advanced-examples)
@@ -300,10 +300,10 @@ print(f"Created index with {len(vector_ids)} vectors")
### FAISS Index Types
```python
-from semantica.vector_store import FAISSAdapter
+from semantica.vector_store import FAISSStore
import numpy as np
-adapter = FAISSAdapter(dimension=768)
+adapter = FAISSStore(dimension=768)
# Create Flat index (exact search)
flat_index = adapter.create_index(index_type="flat", metric="L2")
@@ -334,10 +334,10 @@ pq_index = adapter.create_index(
### Index Training
```python
-from semantica.vector_store import FAISSAdapter
+from semantica.vector_store import FAISSStore
import numpy as np
-adapter = FAISSAdapter(dimension=768)
+adapter = FAISSStore(dimension=768)
# Training vectors
training_vectors = np.random.rand(10000, 768).astype('float32')
@@ -360,10 +360,10 @@ adapter.add_vectors(index, vectors, ids=[f"vec_{i}" for i in range(1000)])
### Index Persistence
```python
-from semantica.vector_store import FAISSAdapter
+from semantica.vector_store import FAISSStore
import numpy as np
-adapter = FAISSAdapter(dimension=768)
+adapter = FAISSStore(dimension=768)
# Create and populate index
index = adapter.create_index(index_type="flat", metric="L2")
@@ -661,46 +661,46 @@ print(f"Tenant1: {len(tenant1_vectors)} vectors")
print(f"Tenant2: {len(tenant2_vectors)} vectors")
```
-## Store Adapters
+## Store Backends
-### FAISS Adapter
+### FAISS Store
```python
-from semantica.vector_store import FAISSAdapter
+from semantica.vector_store import FAISSStore
import numpy as np
-# Create FAISS adapter
-adapter = FAISSAdapter(dimension=768)
+# Create FAISS store
+store = FAISSStore(dimension=768)
# Create index
-index = adapter.create_index(index_type="flat", metric="L2")
+store.create_index(index_type="flat", metric="L2")
# Add vectors
vectors = np.random.rand(1000, 768).astype('float32')
ids = [f"vec_{i}" for i in range(1000)]
-adapter.add_vectors(index, vectors, ids=ids)
+store.add_vectors(vectors, ids=ids)
# Search
query_vector = np.random.rand(768).astype('float32')
-distances, indices = adapter.search(index, query_vector, k=10)
+results = store.search_similar(query_vector, k=10)
-print(f"Found {len(indices)} similar vectors")
+print(f"Found {len(results)} similar vectors")
```
-### Weaviate Adapter
+### Weaviate Store
```python
-from semantica.vector_store import WeaviateAdapter
+from semantica.vector_store import WeaviateStore
import numpy as np
-# Create Weaviate adapter
-adapter = WeaviateAdapter(url="http://localhost:8080")
+# Create Weaviate store
+store = WeaviateStore(url="http://localhost:8080")
# Connect
-adapter.connect()
+store.connect()
# Create schema
-adapter.create_schema(
+store.create_schema(
"Document",
properties=[{"name": "text", "dataType": "text"}]
)
@@ -708,11 +708,11 @@ adapter.create_schema(
# Add objects with vectors
objects = [{"text": f"Document {i}"} for i in range(100)]
vectors = [np.random.rand(768).tolist() for _ in range(100)]
-object_ids = adapter.add_objects(objects, vectors=vectors)
+object_ids = store.add_objects(objects, vectors=vectors)
# Query
query_vector = np.random.rand(768).tolist()
-results = adapter.query_vectors(
+results = store.query_vectors(
query_vector,
limit=10,
where={"category": "science"}
@@ -721,30 +721,30 @@ results = adapter.query_vectors(
print(f"Found {len(results)} results")
```
-### Qdrant Adapter
+### Qdrant Store
```python
-from semantica.vector_store import QdrantAdapter
+from semantica.vector_store import QdrantStore
import numpy as np
-# Create Qdrant adapter
-adapter = QdrantAdapter(url="http://localhost:6333")
+# Create Qdrant store
+store = QdrantStore(url="http://localhost:6333")
# Connect
-adapter.connect()
+store.connect()
# Create collection
-collection = adapter.create_collection("my-collection", dimension=768)
+collection = store.create_collection("my-collection", dimension=768)
# Upsert vectors
vectors = [np.random.rand(768).tolist() for _ in range(100)]
ids = [f"vec_{i}" for i in range(100)]
payloads = [{"category": "science"} for _ in range(100)]
-adapter.upsert_vectors(collection, vectors, ids, payloads)
+store.upsert_vectors(collection, vectors, ids, payloads)
# Search
query_vector = np.random.rand(768).tolist()
-results = adapter.search(
+results = store.search(
collection,
query_vector,
top=10,
@@ -754,20 +754,20 @@ results = adapter.search(
print(f"Found {len(results)} results")
```
-### Milvus Adapter
+### Milvus Store
```python
-from semantica.vector_store import MilvusAdapter
+from semantica.vector_store import MilvusStore
import numpy as np
-# Create Milvus adapter
-adapter = MilvusAdapter(host="localhost", port="19530")
+# Create Milvus store
+store = MilvusStore(host="localhost", port="19530")
# Connect
-adapter.connect()
+store.connect()
# Create collection
-collection = adapter.create_collection(
+collection = store.create_collection(
"my-collection",
dimension=768,
metric_type="L2"
@@ -776,11 +776,11 @@ collection = adapter.create_collection(
# Insert vectors
vectors = np.random.rand(100, 768).astype('float32')
ids = [f"vec_{i}" for i in range(100)]
-adapter.insert_vectors(collection, vectors, ids)
+store.insert_vectors(collection, vectors, ids)
# Search
query_vector = np.random.rand(768).astype('float32')
-results = adapter.search(collection, query_vector, top_k=10)
+results = store.search(collection, query_vector, top_k=10)
print(f"Found {len(results)} results")
```
@@ -862,7 +862,7 @@ results = store.search_vectors(query_vector, k=10)
```python
# ANN search with FAISS
-adapter = FAISSAdapter(dimension=768)
+adapter = FAISSStore(dimension=768)
index = adapter.create_index(index_type="ivf", nlist=100)
results = adapter.search(index, query_vector, k=10)
```
@@ -1170,26 +1170,26 @@ print(f"Found {len(results)} hybrid search results")
### Multi-Backend Vector Store
```python
-from semantica.vector_store import FAISSAdapter, WeaviateAdapter
+from semantica.vector_store import FAISSStore, WeaviateStore
import numpy as np
# Local FAISS store
-faiss_adapter = FAISSAdapter(dimension=768)
-faiss_index = faiss_adapter.create_index(index_type="flat", metric="L2")
+faiss_store = FAISSStore(dimension=768)
+faiss_index = faiss_store.create_index(index_type="flat", metric="L2")
faiss_vectors = np.random.rand(1000, 768).astype('float32')
-faiss_adapter.add_vectors(faiss_index, faiss_vectors, ids=[f"faiss_{i}" for i in range(1000)])
+faiss_store.add_vectors(faiss_index, faiss_vectors, ids=[f"faiss_{i}" for i in range(1000)])
# Self-hosted Weaviate store
-weaviate_adapter = WeaviateAdapter(url="http://localhost:8080")
-weaviate_adapter.connect()
-weaviate_index = weaviate_adapter.create_index("my-index", dimension=768)
+weaviate_store = WeaviateStore(url="http://localhost:8080")
+weaviate_store.connect()
+weaviate_index = weaviate_store.create_index("my-index", dimension=768)
weaviate_vectors = [np.random.rand(768).tolist() for _ in range(1000)]
-weaviate_adapter.upsert_vectors(weaviate_vectors, [f"weaviate_{i}" for i in range(1000)])
+weaviate_store.upsert_vectors(weaviate_vectors, [f"weaviate_{i}" for i in range(1000)])
# Search both
query_vector = np.random.rand(768)
-faiss_results = faiss_adapter.search(faiss_index, query_vector, k=10)
-weaviate_results = weaviate_adapter.query_vectors(query_vector, top_k=10)
+faiss_results = faiss_store.search(faiss_index, query_vector, k=10)
+weaviate_results = weaviate_store.query_vectors(query_vector, top_k=10)
```
### Hybrid Search with Custom Ranking
diff --git a/semantica/vector_store/weaviate_adapter.py b/semantica/vector_store/weaviate_store.py
similarity index 94%
rename from semantica/vector_store/weaviate_adapter.py
rename to semantica/vector_store/weaviate_store.py
index 377886b6..5e53d746 100644
--- a/semantica/vector_store/weaviate_adapter.py
+++ b/semantica/vector_store/weaviate_store.py
@@ -1,5 +1,5 @@
"""
-Weaviate Adapter Module
+Weaviate Store Module
This module provides Weaviate vector database integration for vector storage and
similarity search in the Semantica framework, supporting GraphQL queries, schema
@@ -15,20 +15,20 @@ Key Features:
- Optional dependency handling
Main Classes:
- - WeaviateAdapter: Main Weaviate adapter for vector operations
+ - WeaviateStore: Main Weaviate store for vector operations
- WeaviateClient: Weaviate client wrapper
- WeaviateSchema: Schema builder and validator
- WeaviateQuery: Query builder and executor
Example Usage:
- >>> from semantica.vector_store import WeaviateAdapter
- >>> adapter = WeaviateAdapter(url="http://localhost:8080")
- >>> adapter.connect()
- >>> adapter.create_schema("Document", properties=[{"name": "text", "dataType": "text"}])
- >>> collection = adapter.get_collection("Document")
- >>> object_ids = adapter.add_objects(objects, vectors=vectors)
- >>> results = adapter.query_vectors(query_vector, limit=10, where={"category": "science"})
- >>> results = adapter.graphql_query("{Get {Document {text}}}")
+ >>> from semantica.vector_store import WeaviateStore
+ >>> store = WeaviateStore(url="http://localhost:8080")
+ >>> store.connect()
+ >>> store.create_schema("Document", properties=[{"name": "text", "dataType": "text"}])
+ >>> collection = store.get_collection("Document")
+ >>> object_ids = store.add_objects(objects, vectors=vectors)
+ >>> results = store.query_vectors(query_vector, limit=10, where={"category": "science"})
+ >>> results = store.graphql_query("{Get {Document {text}}}")
Author: Semantica Contributors
License: MIT
@@ -210,9 +210,9 @@ class WeaviateQuery:
raise ProcessingError(f"Failed to get objects: {str(e)}")
-class WeaviateAdapter:
+class WeaviateStore:
"""
- Weaviate adapter for vector storage and similarity search.
+ Weaviate store for vector storage and similarity search.
• Weaviate connection and authentication
• Schema and class management
@@ -225,8 +225,8 @@ class WeaviateAdapter:
def __init__(
self, url: Optional[str] = None, api_key: Optional[str] = None, **config
):
- """Initialize Weaviate adapter."""
- self.logger = get_logger("weaviate_adapter")
+ """Initialize Weaviate store."""
+ self.logger = get_logger("weaviate_store")
self.config = config
self.progress_tracker = get_progress_tracker()
self.url = url or config.get("url", "http://localhost:8080")
@@ -363,7 +363,7 @@ class WeaviateAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="WeaviateAdapter",
+ submodule="WeaviateStore",
message=f"Adding {len(objects)} objects to Weaviate",
)
@@ -438,7 +438,7 @@ class WeaviateAdapter:
"""
tracking_id = self.progress_tracker.start_tracking(
module="vector_store",
- submodule="WeaviateAdapter",
+ submodule="WeaviateStore",
message=f"Querying {limit} similar vectors from Weaviate",
)
diff --git a/test_simple.py b/test_simple.py
new file mode 100644
index 00000000..67bdd6aa
--- /dev/null
+++ b/test_simple.py
@@ -0,0 +1,8 @@
+import unittest
+
+class TestSimple(unittest.TestCase):
+ def test_true(self):
+ self.assertTrue(True)
+
+if __name__ == '__main__':
+ unittest.main()
\ No newline at end of file
diff --git a/tests/test_all_features.py b/tests/test_all_features.py
index 8225baa3..45bb9b67 100644
--- a/tests/test_all_features.py
+++ b/tests/test_all_features.py
@@ -9,7 +9,7 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from semantica.embeddings import EmbeddingGenerator, TextEmbedder
from semantica.vector_store import (
- VectorStore, FAISSAdapter, HybridSearch, MetadataFilter,
+ VectorStore, FAISSStore, HybridSearch, MetadataFilter,
SearchRanker, NamespaceManager
)
@@ -87,23 +87,23 @@ class TestSemanticaFeatures(unittest.TestCase):
self.assertEqual(len(results), 5)
print("VectorStore Basic: OK")
- def test_05_faiss_adapter(self):
- """Test FAISSAdapter directly"""
- print("\nTesting FAISSAdapter...")
- adapter = FAISSAdapter(dimension=768)
- index = adapter.create_index(index_type="hnsw", metric="L2", m=16)
+ def test_05_faiss_store(self):
+ """Test FAISSStore directly"""
+ print("\nTesting FAISSStore...")
+ store = FAISSStore(dimension=768)
+ index = store.create_index(index_type="hnsw", metric="L2", m=16)
vectors = np.random.rand(100, 768).astype('float32')
ids = [f"doc_{i}" for i in range(len(vectors))]
# Add vectors
- adapter.add_vectors(vectors, ids=ids)
+ store.add_vectors(vectors, ids=ids)
# Search
query = np.random.rand(768).astype('float32')
- results = adapter.search_similar(query, k=5)
+ results = store.search_similar(query, k=5)
self.assertEqual(len(results), 5)
- print("FAISSAdapter: OK")
+ print("FAISSStore: OK")
def test_06_hybrid_search(self):
"""Test Hybrid Search with Metadata Filtering"""
diff --git a/tests/test_graph_store.py b/tests/test_graph_store.py
index 0d0e564a..26e40581 100644
--- a/tests/test_graph_store.py
+++ b/tests/test_graph_store.py
@@ -3,7 +3,7 @@ from unittest.mock import MagicMock, patch
from typing import Any, Dict, List, Optional
from semantica.graph_store.graph_store import GraphStore
-class MockGraphAdapter:
+class MockGraphStore:
def __init__(self, **config):
self.config = config
self.nodes = {}
@@ -140,9 +140,9 @@ class MockGraphAdapter:
class TestGraphStore(unittest.TestCase):
def setUp(self):
- # Patch Neo4jAdapter to return our MockGraphAdapter
- self.patcher = patch('semantica.graph_store.neo4j_adapter.Neo4jAdapter', side_effect=MockGraphAdapter)
- self.mock_adapter_class = self.patcher.start()
+ # Patch Neo4jStore to return our MockGraphStore
+ self.patcher = patch('semantica.graph_store.neo4j_store.Neo4jStore', side_effect=MockGraphStore)
+ self.mock_store_class = self.patcher.start()
# Initialize GraphStore with 'neo4j' backend (which will use our mock)
self.store = GraphStore(backend="neo4j")
@@ -211,15 +211,15 @@ class TestGraphStore(unittest.TestCase):
self.assertEqual(created_nodes[1]["properties"]["name"], "User2")
def test_query_execution(self):
- # Since MockGraphAdapter returns a fixed response
+ # Since MockGraphStore returns a fixed response
result = self.store.execute_query("MATCH (n) RETURN n")
self.assertEqual(result["summary"], "Mock query executed")
class TestGraphStoreInitialization(unittest.TestCase):
def test_falkordb_initialization(self):
- with patch('semantica.graph_store.falkordb_adapter.FalkorDBAdapter', side_effect=MockGraphAdapter) as mock_falkor:
+ with patch('semantica.graph_store.falkordb_store.FalkorDBStore', side_effect=MockGraphStore) as mock_falkor:
store = GraphStore(backend="falkordb")
- self.assertIsInstance(store._adapter, MockGraphAdapter)
+ self.assertIsInstance(store._store_backend, MockGraphStore)
mock_falkor.assert_called_once()
def test_invalid_backend(self):
diff --git a/tests/test_notebooks_plain.py b/tests/test_notebooks_plain.py
index cb446304..e017ce5b 100644
--- a/tests/test_notebooks_plain.py
+++ b/tests/test_notebooks_plain.py
@@ -83,24 +83,24 @@ def test_13_vector_store_basic():
def test_advanced_vector_store():
log("\nTesting Advanced_Vector_Store_and_Search.ipynb logic...")
try:
- from semantica.vector_store import FAISSAdapter, HybridSearch, MetadataFilter, SearchRanker, NamespaceManager
+ from semantica.vector_store import FAISSStore, HybridSearch, MetadataFilter, SearchRanker, NamespaceManager
- # Part 1: FAISSAdapter
- adapter = FAISSAdapter(dimension=768)
- index = adapter.create_index(index_type="hnsw", metric="L2", m=16)
+ # Part 1: FAISSStore
+ store = FAISSStore(dimension=768)
+ index = store.create_index(index_type="hnsw", metric="L2", m=16)
vectors = np.random.rand(100, 768).astype('float32')
ids = [f"doc_{i}" for i in range(len(vectors))]
# Note: API does not take index as first argument, it uses internal self.index
- adapter.add_vectors(vectors, ids=ids)
+ store.add_vectors(vectors, ids=ids)
query = np.random.rand(768).astype('float32')
# Use search_similar which returns structured results
- results = adapter.search_similar(query, k=5)
+ results = store.search_similar(query, k=5)
if len(results) != 5:
raise ValueError(f"Expected 5 results, got {len(results)}")
- log("FAISSAdapter: OK")
+ log("FAISSStore: OK")
# Part 2: HybridSearch
search = HybridSearch()
diff --git a/tests/test_notebooks_repro.py b/tests/test_notebooks_repro.py
index c0915721..ee1960eb 100644
--- a/tests/test_notebooks_repro.py
+++ b/tests/test_notebooks_repro.py
@@ -68,19 +68,22 @@ class TestNotebooks(unittest.TestCase):
def test_advanced_vector_store(self):
print("\nTesting Advanced_Vector_Store_and_Search.ipynb logic...")
try:
- from semantica.vector_store import FAISSAdapter, HybridSearch, MetadataFilter, SearchRanker, NamespaceManager
+ from semantica.vector_store import FAISSStore, HybridSearch, MetadataFilter, SearchRanker, NamespaceManager
- # Part 1: FAISSAdapter
- adapter = FAISSAdapter(dimension=768)
- index = adapter.create_index(index_type="hnsw", metric="L2", m=16)
+ # Part 1: FAISSStore
+ store = FAISSStore(dimension=768)
+ index = store.create_index(index_type="hnsw", metric="L2", m=16)
vectors = np.random.rand(100, 768).astype('float32')
ids = [f"doc_{i}" for i in range(len(vectors))]
- adapter.add_vectors(index, vectors, ids=ids)
+ store.add_vectors(vectors, ids=ids)
query = np.random.rand(768).astype('float32')
- distances, indices = adapter.search(index, query, k=5)
- self.assertEqual(len(indices), 5)
- print("FAISSAdapter: OK")
+ results = store.search_similar(query, k=5)
+ # Check results structure
+ self.assertEqual(len(results), 5)
+ self.assertTrue(isinstance(results[0], dict))
+ self.assertIn("id", results[0])
+ print("FAISSStore: OK")
# Part 2: Hybrid Search
search = HybridSearch()
diff --git a/tests/triplet_store/test_triplet_store.py b/tests/triplet_store/test_triplet_store.py
index d4d90f4f..07381800 100644
--- a/tests/triplet_store/test_triplet_store.py
+++ b/tests/triplet_store/test_triplet_store.py
@@ -40,30 +40,30 @@ class TestTripletStore(unittest.TestCase):
self.assertEqual(store.endpoint, "http://localhost:9999")
self.assertIn("main", manager.stores)
- @patch('semantica.triplet_store.triplet_manager.TripletManager._get_adapter')
- def test_add_triplet(self, mock_get_adapter):
+ @patch('semantica.triplet_store.triplet_manager.TripletManager._get_store_backend')
+ def test_add_triplet(self, mock_get_store_backend):
manager = TripletManager()
manager.register_store("main", "blazegraph", "http://localhost:9999")
- mock_adapter = MagicMock()
- mock_get_adapter.return_value = mock_adapter
- mock_adapter.add_triplet.return_value = {"status": "success"}
+ mock_store = MagicMock()
+ mock_get_store_backend.return_value = mock_store
+ mock_store.add_triplet.return_value = {"status": "success"}
triplet = Triplet(subject="s", predicate="p", object="o")
result = manager.add_triplet(triplet, store_id="main")
self.assertTrue(result["success"])
self.assertEqual(result["store_id"], "main")
- mock_adapter.add_triplet.assert_called_once_with(triplet)
+ mock_store.add_triplet.assert_called_once_with(triplet)
- @patch('semantica.triplet_store.triplet_manager.TripletManager._get_adapter')
- def test_add_triplets(self, mock_get_adapter):
+ @patch('semantica.triplet_store.triplet_manager.TripletManager._get_store_backend')
+ def test_add_triplets(self, mock_get_store_backend):
manager = TripletManager()
manager.register_store("main", "blazegraph", "http://localhost:9999")
- mock_adapter = MagicMock()
- mock_get_adapter.return_value = mock_adapter
- mock_adapter.add_triplets.return_value = {"status": "success"}
+ mock_store = MagicMock()
+ mock_get_store_backend.return_value = mock_store
+ mock_store.add_triplets.return_value = {"status": "success"}
triplets = [
Triplet(subject="s1", predicate="p1", object="o1"),
@@ -74,47 +74,47 @@ class TestTripletStore(unittest.TestCase):
self.assertTrue(result["success"])
self.assertEqual(result["store_id"], "main")
- mock_adapter.add_triplets.assert_called()
+ mock_store.add_triplets.assert_called()
- @patch('semantica.triplet_store.triplet_manager.TripletManager._get_adapter')
- def test_get_triplets(self, mock_get_adapter):
+ @patch('semantica.triplet_store.triplet_manager.TripletManager._get_store_backend')
+ def test_get_triplets(self, mock_get_store_backend):
manager = TripletManager()
manager.register_store("main", "blazegraph", "http://localhost:9999")
- mock_adapter = MagicMock()
- mock_get_adapter.return_value = mock_adapter
+ mock_store = MagicMock()
+ mock_get_store_backend.return_value = mock_store
expected_triplets = [Triplet(subject="s", predicate="p", object="o")]
- mock_adapter.get_triplets.return_value = expected_triplets
+ mock_store.get_triplets.return_value = expected_triplets
result = manager.get_triplets(subject="s", store_id="main")
self.assertEqual(result, expected_triplets)
- mock_adapter.get_triplets.assert_called_once_with("s", None, None)
+ mock_store.get_triplets.assert_called_once_with("s", None, None)
- @patch('semantica.triplet_store.triplet_manager.TripletManager._get_adapter')
- def test_delete_triplet(self, mock_get_adapter):
+ @patch('semantica.triplet_store.triplet_manager.TripletManager._get_store_backend')
+ def test_delete_triplet(self, mock_get_store_backend):
manager = TripletManager()
manager.register_store("main", "blazegraph", "http://localhost:9999")
- mock_adapter = MagicMock()
- mock_get_adapter.return_value = mock_adapter
- mock_adapter.delete_triplet.return_value = {"status": "deleted"}
+ mock_store = MagicMock()
+ mock_get_store_backend.return_value = mock_store
+ mock_store.delete_triplet.return_value = {"status": "deleted"}
triplet = Triplet(subject="s", predicate="p", object="o")
result = manager.delete_triplet(triplet, store_id="main")
self.assertTrue(result["success"])
- mock_adapter.delete_triplet.assert_called_once_with(triplet)
+ mock_store.delete_triplet.assert_called_once_with(triplet)
- @patch('semantica.triplet_store.triplet_manager.TripletManager._get_adapter')
- def test_update_triplet(self, mock_get_adapter):
+ @patch('semantica.triplet_store.triplet_manager.TripletManager._get_store_backend')
+ def test_update_triplet(self, mock_get_store_backend):
manager = TripletManager()
manager.register_store("main", "blazegraph", "http://localhost:9999")
- mock_adapter = MagicMock()
- mock_get_adapter.return_value = mock_adapter
- mock_adapter.delete_triplet.return_value = {"status": "deleted"}
- mock_adapter.add_triplet.return_value = {"status": "added"}
+ mock_store = MagicMock()
+ mock_get_store_backend.return_value = mock_store
+ mock_store.delete_triplet.return_value = {"status": "deleted"}
+ mock_store.add_triplet.return_value = {"status": "added"}
old_triplet = Triplet(subject="s", predicate="p", object="o_old")
new_triplet = Triplet(subject="s", predicate="p", object="o_new")
@@ -122,8 +122,8 @@ class TestTripletStore(unittest.TestCase):
result = manager.update_triplet(old_triplet, new_triplet, store_id="main")
self.assertTrue(result["success"])
- mock_adapter.delete_triplet.assert_called_once_with(old_triplet)
- mock_adapter.add_triplet.assert_called_once_with(new_triplet)
+ mock_store.delete_triplet.assert_called_once_with(old_triplet)
+ mock_store.add_triplet.assert_called_once_with(new_triplet)
def test_query_engine_init(self):
engine = QueryEngine(enable_caching=True)
diff --git a/tests/vector_store/test_pinecone_removal.py b/tests/vector_store/test_pinecone_removal.py
index 0f869334..3677d1fa 100644
--- a/tests/vector_store/test_pinecone_removal.py
+++ b/tests/vector_store/test_pinecone_removal.py
@@ -45,18 +45,18 @@ class TestPineconeRemoval(unittest.TestCase):
for key in config.keys():
self.assertNotIn("pinecone", key.lower(), f"Found pinecone key in config: {key}")
- def test_adapters_existence(self):
- """Verify that other adapters exist but PineconeAdapter does not."""
+ def test_stores_existence(self):
+ """Verify that other stores exist but PineconeStore does not."""
try:
- from semantica.vector_store import faiss_adapter
- from semantica.vector_store import weaviate_adapter
- from semantica.vector_store import qdrant_adapter
- from semantica.vector_store import milvus_adapter
+ from semantica.vector_store import faiss_store
+ from semantica.vector_store import weaviate_store
+ from semantica.vector_store import qdrant_store
+ from semantica.vector_store import milvus_store
except ImportError as e:
- self.fail(f"Failed to import a required adapter: {e}")
+ self.fail(f"Failed to import a required store: {e}")
with self.assertRaises(ImportError):
- from semantica.vector_store import pinecone_adapter
+ from semantica.vector_store import pinecone_store
if __name__ == '__main__':
unittest.main()
diff --git a/tests/vector_store/test_vector_store_deepdive.py b/tests/vector_store/test_vector_store_deepdive.py
index 5f579833..2cd2bf94 100644
--- a/tests/vector_store/test_vector_store_deepdive.py
+++ b/tests/vector_store/test_vector_store_deepdive.py
@@ -10,10 +10,10 @@ sys.path.append(str(Path(__file__).parent.parent.parent))
from semantica.vector_store.vector_store import VectorStore, VectorIndexer, VectorRetriever, VectorManager
from semantica.vector_store.registry import MethodRegistry, method_registry
-from semantica.vector_store.faiss_adapter import FAISSAdapter, FAISSIndex, FAISSIndexBuilder, FAISSSearch
-from semantica.vector_store.milvus_adapter import MilvusAdapter, MilvusClient, MilvusCollection, MilvusSearch
-from semantica.vector_store.qdrant_adapter import QdrantAdapter
-from semantica.vector_store.weaviate_adapter import WeaviateAdapter
+from semantica.vector_store.faiss_store import FAISSStore, FAISSIndex, FAISSIndexBuilder, FAISSSearch
+from semantica.vector_store.milvus_store import MilvusStore, MilvusClient, MilvusCollection, MilvusSearch
+from semantica.vector_store.qdrant_store import QdrantStore
+from semantica.vector_store.weaviate_store import WeaviateStore
from semantica.vector_store.hybrid_search import HybridSearch, MetadataFilter, SearchRanker
pytestmark = pytest.mark.integration
@@ -110,10 +110,10 @@ class TestVectorStoreDeepDive(unittest.TestCase):
registry.unregister("store", "custom")
self.assertFalse(registry.has("store", "custom"))
- @patch('semantica.vector_store.faiss_adapter.faiss')
- @patch('semantica.vector_store.faiss_adapter.FAISS_AVAILABLE', True)
- def test_faiss_adapter(self, mock_faiss):
- """Test FAISSAdapter with mocked faiss."""
+ @patch('semantica.vector_store.faiss_store.faiss')
+ @patch('semantica.vector_store.faiss_store.FAISS_AVAILABLE', True)
+ def test_faiss_store(self, mock_faiss):
+ """Test FAISSStore with mocked faiss."""
# Setup mock
mock_index = MagicMock()
mock_faiss.IndexFlatL2.return_value = mock_index
@@ -125,39 +125,39 @@ class TestVectorStoreDeepDive(unittest.TestCase):
mock_index.ntotal = 2
# Test Init
- adapter = FAISSAdapter(dimension=2)
+ store = FAISSStore(dimension=2)
# Test Create Index
- adapter.create_index(index_type="flat")
+ store.create_index(index_type="flat")
mock_faiss.IndexFlatL2.assert_called_with(2)
# Test Add Vectors
- adapter.add_vectors(self.vectors, self.ids, self.metadata)
+ store.add_vectors(self.vectors, self.ids, self.metadata)
mock_index.add.assert_called()
- self.assertEqual(len(adapter.index.vector_ids), 2)
+ self.assertEqual(len(store.index.vector_ids), 2)
# Test Search
- results = adapter.search_similar(np.array([1.0, 0.0]), k=2)
+ results = store.search_similar(np.array([1.0, 0.0]), k=2)
self.assertEqual(len(results), 2)
self.assertEqual(results[0]["id"], "vec_1")
# Test Save
- adapter.save_index("test.index")
+ store.save_index("test.index")
mock_faiss.write_index.assert_called()
# Test Load
- adapter.load_index("test.index")
+ store.load_index("test.index")
mock_faiss.read_index.assert_called()
- @patch('semantica.vector_store.milvus_adapter.connections')
- @patch('semantica.vector_store.milvus_adapter.Collection')
- @patch('semantica.vector_store.milvus_adapter.utility')
- @patch('semantica.vector_store.milvus_adapter.DataType')
- @patch('semantica.vector_store.milvus_adapter.FieldSchema')
- @patch('semantica.vector_store.milvus_adapter.CollectionSchema')
- @patch('semantica.vector_store.milvus_adapter.MILVUS_AVAILABLE', True)
- def test_milvus_adapter(self, mock_collection_schema, mock_field_schema, mock_data_type, mock_utility, mock_collection_cls, mock_connections):
- """Test MilvusAdapter with mocked pymilvus."""
+ @patch('semantica.vector_store.milvus_store.connections')
+ @patch('semantica.vector_store.milvus_store.Collection')
+ @patch('semantica.vector_store.milvus_store.utility')
+ @patch('semantica.vector_store.milvus_store.DataType')
+ @patch('semantica.vector_store.milvus_store.FieldSchema')
+ @patch('semantica.vector_store.milvus_store.CollectionSchema')
+ @patch('semantica.vector_store.milvus_store.MILVUS_AVAILABLE', True)
+ def test_milvus_store(self, mock_collection_schema, mock_field_schema, mock_data_type, mock_utility, mock_collection_cls, mock_connections):
+ """Test MilvusStore with mocked pymilvus."""
# Setup mocks
mock_data_type.INT64 = 1
mock_data_type.FLOAT_VECTOR = 2
@@ -173,36 +173,36 @@ class TestVectorStoreDeepDive(unittest.TestCase):
mock_collection_instance.search.return_value = [[mock_hit]]
# Test Init
- adapter = MilvusAdapter(host="localhost")
+ store = MilvusStore(host="localhost")
# Test Connect
- adapter.connect()
+ store.connect()
mock_connections.connect.assert_called_with(
alias="default", host="localhost", port=19530, user=None, password=None
)
# Test Create Collection
- adapter.create_collection("test_coll", dimension=2)
+ store.create_collection("test_coll", dimension=2)
mock_collection_cls.assert_called()
mock_collection_instance.create_index.assert_called()
# Test Insert
- adapter.insert_vectors(self.vectors)
+ store.insert_vectors(self.vectors)
mock_collection_instance.insert.assert_called()
# Test Search
- results = adapter.search_vectors(np.array([1.0, 0.0]), limit=1)
+ results = store.search_vectors(np.array([1.0, 0.0]), limit=1)
mock_collection_instance.search.assert_called()
self.assertEqual(len(results), 1)
self.assertEqual(results[0]["id"], 1)
- @patch('semantica.vector_store.qdrant_adapter.QdrantClientLib')
- @patch('semantica.vector_store.qdrant_adapter.VectorParams')
- @patch('semantica.vector_store.qdrant_adapter.Distance')
- @patch('semantica.vector_store.qdrant_adapter.PointStruct')
- @patch('semantica.vector_store.qdrant_adapter.QDRANT_AVAILABLE', True)
- def test_qdrant_adapter(self, mock_point_struct, mock_distance, mock_vector_params, mock_qdrant_cls):
- """Test QdrantAdapter with mocked qdrant_client."""
+ @patch('semantica.vector_store.qdrant_store.QdrantClientLib')
+ @patch('semantica.vector_store.qdrant_store.VectorParams')
+ @patch('semantica.vector_store.qdrant_store.Distance')
+ @patch('semantica.vector_store.qdrant_store.PointStruct')
+ @patch('semantica.vector_store.qdrant_store.QDRANT_AVAILABLE', True)
+ def test_qdrant_store(self, mock_point_struct, mock_distance, mock_vector_params, mock_qdrant_cls):
+ """Test QdrantStore with mocked qdrant_client."""
mock_client = MagicMock()
mock_qdrant_cls.return_value = mock_client
@@ -213,30 +213,30 @@ class TestVectorStoreDeepDive(unittest.TestCase):
mock_hit.payload = {"type": "a"}
mock_client.search.return_value = [mock_hit]
- adapter = QdrantAdapter(url="http://localhost:6333")
+ store = QdrantStore(url="http://localhost:6333")
# Connect
- adapter.connect()
+ store.connect()
mock_qdrant_cls.assert_called()
# Create Collection
- adapter.create_collection("test-collection", vector_size=2)
+ store.create_collection("test-collection", vector_size=2)
mock_client.create_collection.assert_called()
# Insert
- adapter.insert_vectors(self.vectors, self.ids, payloads=self.metadata)
+ store.insert_vectors(self.vectors, self.ids, payloads=self.metadata)
mock_client.upsert.assert_called()
# Search
- results = adapter.search_vectors(np.array([1.0, 0.0]), limit=1)
+ results = store.search_vectors(np.array([1.0, 0.0]), limit=1)
self.assertEqual(len(results), 1)
self.assertEqual(results[0]["id"], "vec_1")
- @patch('semantica.vector_store.weaviate_adapter.weaviate')
- @patch('semantica.vector_store.weaviate_adapter.MetadataQuery')
- @patch('semantica.vector_store.weaviate_adapter.WEAVIATE_AVAILABLE', True)
- def test_weaviate_adapter(self, mock_metadata_query, mock_weaviate):
- """Test WeaviateAdapter with mocked weaviate."""
+ @patch('semantica.vector_store.weaviate_store.weaviate')
+ @patch('semantica.vector_store.weaviate_store.MetadataQuery')
+ @patch('semantica.vector_store.weaviate_store.WEAVIATE_AVAILABLE', True)
+ def test_weaviate_store(self, mock_metadata_query, mock_weaviate):
+ """Test WeaviateStore with mocked weaviate."""
mock_client = MagicMock()
mock_weaviate.connect_to_local.return_value = mock_client
@@ -254,14 +254,14 @@ class TestVectorStoreDeepDive(unittest.TestCase):
mock_collection.query.near_vector.return_value = mock_query_response
- adapter = WeaviateAdapter(url="http://localhost:8080")
+ store = WeaviateStore(url="http://localhost:8080")
# Connect
- adapter.connect()
+ store.connect()
mock_weaviate.connect_to_local.assert_called()
# Create Schema
- adapter.create_schema("TestClass", properties=[])
+ store.create_schema("TestClass", properties=[])
mock_client.collections.create.assert_called()
# Add Objects
@@ -269,12 +269,12 @@ class TestVectorStoreDeepDive(unittest.TestCase):
mock_batch = MagicMock()
mock_collection.batch.dynamic.return_value.__enter__.return_value = mock_batch
- adapter.get_collection("TestClass")
- adapter.add_objects([{"text": "hello"}], vectors=self.vectors)
+ store.get_collection("TestClass")
+ store.add_objects([{"text": "hello"}], vectors=self.vectors)
mock_batch.add_object.assert_called()
# Query
- results = adapter.query_vectors(np.array([1.0, 0.0]), limit=1)
+ results = store.query_vectors(np.array([1.0, 0.0]), limit=1)
self.assertEqual(len(results), 1)
self.assertEqual(results[0]["id"], "uuid-1")
@@ -293,7 +293,7 @@ class TestVectorStoreDeepDive(unittest.TestCase):
# Test Search
results = search.search(
- query_vector=np.array([1.0, 0.0]),
+ query=np.array([1.0, 0.0]),
vectors=self.vectors,
metadata=self.metadata,
vector_ids=self.ids,
@@ -304,7 +304,7 @@ class TestVectorStoreDeepDive(unittest.TestCase):
# Test Filtered Search
results = search.search(
- query_vector=np.array([1.0, 0.0]),
+ query=np.array([1.0, 0.0]),
vectors=self.vectors,
metadata=self.metadata,
vector_ids=self.ids,
diff --git a/update_codebase_refs.py b/update_codebase_refs.py
new file mode 100644
index 00000000..bc41f03c
--- /dev/null
+++ b/update_codebase_refs.py
@@ -0,0 +1,57 @@
+import os
+
+replacements = [
+ ("Adapter Pattern", "Backend Pattern"),
+ ("Store Adapters", "Store Backends"),
+ ("Store Adapter", "Store Backend"),
+ ("FAISSAdapter", "FAISSStore"),
+ ("MilvusAdapter", "MilvusStore"),
+ ("QdrantAdapter", "QdrantStore"),
+ ("WeaviateAdapter", "WeaviateStore"),
+ ("Neo4jAdapter", "Neo4jStore"),
+ ("FalkorDBAdapter", "FalkorDBStore"),
+ ("BlazegraphAdapter", "BlazegraphStore"),
+ ("JenaAdapter", "JenaStore"),
+ ("RDF4JAdapter", "RDF4JStore"),
+ ("VirtuosoAdapter", "VirtuosoStore"),
+ ("faiss_adapter", "faiss_store"),
+ ("milvus_adapter", "milvus_store"),
+ ("qdrant_adapter", "qdrant_store"),
+ ("weaviate_adapter", "weaviate_store"),
+ ("neo4j_adapter", "neo4j_store"),
+ ("falkordb_adapter", "falkordb_store"),
+ ("blazegraph_adapter", "blazegraph_store"),
+ ("jena_adapter", "jena_store"),
+ ("rdf4j_adapter", "rdf4j_store"),
+ ("virtuoso_adapter", "virtuoso_store"),
+ ("store_adapter", "store_backend"),
+]
+
+files = [
+ "semantica/vector_store/__init__.py",
+ "semantica/graph_store/__init__.py",
+ "semantica/vector_store/vector_store_usage.md",
+ "semantica/graph_store/graph_store_usage.md",
+ "semantica/triplet_store/triplet_store_usage.md",
+ "tests/test_graph_store.py",
+ "tests/vector_store/test_pinecone_removal.py",
+ "cookbook/introduction/20_Triplet_Store.ipynb",
+]
+
+for file_path in files:
+ if os.path.exists(file_path):
+ with open(file_path, 'r', encoding='utf-8') as f:
+ content = f.read()
+
+ original_content = content
+ for old, new in replacements:
+ content = content.replace(old, new)
+
+ if content != original_content:
+ with open(file_path, 'w', encoding='utf-8') as f:
+ f.write(content)
+ print(f"Updated {file_path}")
+ else:
+ print(f"No changes in {file_path}")
+ else:
+ print(f"File not found: {file_path}")
diff --git a/update_project_refs.py b/update_project_refs.py
new file mode 100644
index 00000000..f41e7e0a
--- /dev/null
+++ b/update_project_refs.py
@@ -0,0 +1,80 @@
+import os
+
+root_dir = r"c:/Users/Mohd Kaif/semantica"
+
+replacements = {
+ # Class names
+ "FAISSAdapter": "FAISSStore",
+ "MilvusAdapter": "MilvusStore",
+ "QdrantAdapter": "QdrantStore",
+ "WeaviateAdapter": "WeaviateStore",
+ "FalkorDBAdapter": "FalkorDBStore",
+ "Neo4jAdapter": "Neo4jStore",
+
+ # Filename references in imports
+ "semantica.vector_store.faiss_adapter": "semantica.vector_store.faiss_store",
+ "semantica.vector_store.milvus_adapter": "semantica.vector_store.milvus_store",
+ "semantica.vector_store.qdrant_adapter": "semantica.vector_store.qdrant_store",
+ "semantica.vector_store.weaviate_adapter": "semantica.vector_store.weaviate_store",
+ "semantica.graph_store.falkordb_adapter": "semantica.graph_store.falkordb_store",
+ "semantica.graph_store.neo4j_adapter": "semantica.graph_store.neo4j_store",
+
+ # Module references (local imports)
+ "from .faiss_adapter": "from .faiss_store",
+ "from .milvus_adapter": "from .milvus_store",
+ "from .qdrant_adapter": "from .qdrant_store",
+ "from .weaviate_adapter": "from .weaviate_store",
+ "from .falkordb_adapter": "from .falkordb_store",
+ "from .neo4j_adapter": "from .neo4j_store",
+
+ # Variable names (optional but requested "better nameing")
+ # "faiss_adapter": "faiss_store",
+ # "milvus_adapter": "milvus_store",
+ # Be careful with variable names, but let's try to be consistent if it's safe.
+ # I'll stick to explicit classes and imports first to avoid breaking local vars too much unless I'm sure.
+ # Actually user said "Change all the name from adapter to store... update everything".
+ # I'll replace "Adapter" with "Store" in text/comments if it refers to the class.
+
+ # Docstrings and Text
+ "FAISS Adapter": "FAISS Store",
+ "Milvus Adapter": "Milvus Store",
+ "Qdrant Adapter": "Qdrant Store",
+ "Weaviate Adapter": "Weaviate Store",
+ "FalkorDB Adapter": "FalkorDB Store",
+ "Neo4j Adapter": "Neo4j Store",
+
+ # Generic "Adapter" to "Store" in specific contexts?
+ # Maybe risky. Let's stick to the specific ones.
+}
+
+extensions = ['.py', '.ipynb', '.md']
+
+for root, dirs, files in os.walk(root_dir):
+ if ".git" in root or "__pycache__" in root:
+ continue
+
+ for file in files:
+ if any(file.endswith(ext) for ext in extensions):
+ file_path = os.path.join(root, file)
+ # Skip the script itself
+ if "update_project_refs.py" in file_path or "update_store_names.py" in file_path:
+ continue
+
+ try:
+ with open(file_path, 'r', encoding='utf-8') as f:
+ content = f.read()
+
+ new_content = content
+ changed = False
+ for old, new in replacements.items():
+ if old in new_content:
+ new_content = new_content.replace(old, new)
+ changed = True
+
+ if changed:
+ with open(file_path, 'w', encoding='utf-8') as f:
+ f.write(new_content)
+ print(f"Updated {file_path}")
+ except Exception as e:
+ print(f"Error processing {file_path}: {e}")
+
diff --git a/update_store_names.py b/update_store_names.py
new file mode 100644
index 00000000..05211701
--- /dev/null
+++ b/update_store_names.py
@@ -0,0 +1,47 @@
+import os
+
+files_to_update = [
+ r"c:/Users/Mohd Kaif/semantica/semantica/vector_store/faiss_store.py",
+ r"c:/Users/Mohd Kaif/semantica/semantica/vector_store/milvus_store.py",
+ r"c:/Users/Mohd Kaif/semantica/semantica/vector_store/qdrant_store.py",
+ r"c:/Users/Mohd Kaif/semantica/semantica/vector_store/weaviate_store.py",
+ r"c:/Users/Mohd Kaif/semantica/semantica/graph_store/falkordb_store.py",
+ r"c:/Users/Mohd Kaif/semantica/semantica/graph_store/neo4j_store.py"
+]
+
+replacements = {
+ "FAISSAdapter": "FAISSStore",
+ "MilvusAdapter": "MilvusStore",
+ "QdrantAdapter": "QdrantStore",
+ "WeaviateAdapter": "WeaviateStore",
+ "FalkorDBAdapter": "FalkorDBStore",
+ "Neo4jAdapter": "Neo4jStore",
+ "FAISS adapter": "FAISS store",
+ "Milvus adapter": "Milvus store",
+ "Qdrant adapter": "Qdrant store",
+ "Weaviate adapter": "Weaviate store",
+ "FalkorDB adapter": "FalkorDB store",
+ "Neo4j adapter": "Neo4j store",
+ "faiss_adapter": "faiss_store",
+ "milvus_adapter": "milvus_store",
+ "qdrant_adapter": "qdrant_store",
+ "weaviate_adapter": "weaviate_store",
+ "falkordb_adapter": "falkordb_store",
+ "neo4j_adapter": "neo4j_store"
+}
+
+for file_path in files_to_update:
+ if not os.path.exists(file_path):
+ print(f"File not found: {file_path}")
+ continue
+
+ with open(file_path, 'r', encoding='utf-8') as f:
+ content = f.read()
+
+ new_content = content
+ for old, new in replacements.items():
+ new_content = new_content.replace(old, new)
+
+ with open(file_path, 'w', encoding='utf-8') as f:
+ f.write(new_content)
+ print(f"Updated {file_path}")
diff --git a/update_triplet_store.py b/update_triplet_store.py
new file mode 100644
index 00000000..5ed120df
--- /dev/null
+++ b/update_triplet_store.py
@@ -0,0 +1,49 @@
+import os
+
+replacements = {
+ "semantica/triplet_store/blazegraph_store.py": ("BlazegraphAdapter", "BlazegraphStore"),
+ "semantica/triplet_store/jena_store.py": ("JenaAdapter", "JenaStore"),
+ "semantica/triplet_store/rdf4j_store.py": ("RDF4JAdapter", "RDF4JStore"),
+ "semantica/triplet_store/virtuoso_store.py": ("VirtuosoAdapter", "VirtuosoStore"),
+}
+
+for file_path, (old, new) in replacements.items():
+ if os.path.exists(file_path):
+ with open(file_path, 'r', encoding='utf-8') as f:
+ content = f.read()
+
+ new_content = content.replace(old, new)
+
+ with open(file_path, 'w', encoding='utf-8') as f:
+ f.write(new_content)
+ print(f"Updated {file_path}")
+ else:
+ print(f"File not found: {file_path}")
+
+# Update __init__.py
+init_path = "semantica/triplet_store/__init__.py"
+if os.path.exists(init_path):
+ with open(init_path, 'r', encoding='utf-8') as f:
+ content = f.read()
+
+ # Update imports
+ content = content.replace("from .blazegraph_adapter import BlazegraphAdapter", "from .blazegraph_store import BlazegraphStore")
+ content = content.replace("from .jena_adapter import JenaAdapter", "from .jena_store import JenaStore")
+ content = content.replace("from .rdf4j_adapter import RDF4JAdapter", "from .rdf4j_store import RDF4JStore")
+ content = content.replace("from .virtuoso_adapter import VirtuosoAdapter", "from .virtuoso_store import VirtuosoStore")
+
+ # Update __all__ and other references
+ content = content.replace("BlazegraphAdapter", "BlazegraphStore")
+ content = content.replace("JenaAdapter", "JenaStore")
+ content = content.replace("RDF4JAdapter", "RDF4JStore")
+ content = content.replace("VirtuosoAdapter", "VirtuosoStore")
+
+ # Update docstrings
+ content = content.replace("Store Adapters:", "Store Backends:")
+ content = content.replace("Store Adapter Pattern", "Store Backend Pattern")
+ content = content.replace("Adapter Pattern:", "Backend Pattern:")
+ content = content.replace("Adapter Pattern", "Backend Pattern")
+
+ with open(init_path, 'w', encoding='utf-8') as f:
+ f.write(content)
+ print(f"Updated {init_path}")