Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

Update cookbook/introduction/18_Deduplication.ipynb

KaifAhmad11620de371f61
diff --git a/cookbook/introduction/18_Deduplication.ipynb b/cookbook/introduction/18_Deduplication.ipynb
index 0b183aba..d5e8dc52 100644
--- a/cookbook/introduction/18_Deduplication.ipynb
+++ b/cookbook/introduction/18_Deduplication.ipynb
@@ -146,7 +146,7 @@
{
"data": {
"text/html": [
- "<div style='font-family: monospace;'><h4>🧠 Semantica - πŸ“Š Current Progress</h4><table style='width: 100%; border-collapse: collapse;'><tr><th>Status</th><th>Action</th><th>Module</th><th>Submodule</th><th>File</th><th>Time</th></tr><tr><td>βœ…</td><td>Semantica is deduplicating</td><td>πŸ”„ deduplication</td><td>SimilarityCalculator</td><td>-</td><td>0.01s</td></tr><tr><td>βœ…</td><td>Semantica is deduplicating</td><td>πŸ”„ deduplication</td><td>DuplicateDetector</td><td>-</td><td>0.17s</td></tr><tr><td>βœ…</td><td>Semantica is deduplicating</td><td>πŸ”„ deduplication</td><td>EntityMerger</td><td>-</td><td>0.18s</td></tr></table></div>"
+ "<div style='font-family: monospace;'><h4>🧠 Semantica - πŸ“Š Current Progress</h4><table style='width: 100%; border-collapse: collapse;'><tr><th>Status</th><th>Action</th><th>Module</th><th>Submodule</th><th>File</th><th>Time</th></tr><tr><td>βœ…</td><td>Semantica is deduplicating</td><td>πŸ”„ deduplication</td><td>SimilarityCalculator</td><td>-</td><td>0.01s</td></tr><tr><td>βœ…</td><td>Semantica is deduplicating</td><td>πŸ”„ deduplication</td><td>DuplicateDetector</td><td>-</td><td>0.17s</td></tr><tr><td>βœ…</td><td>Semantica is deduplicating</td><td>πŸ”„ deduplication</td><td>EntityMerger</td><td>-</td><td>0.19s</td></tr><tr><td>βœ…</td><td>Semantica is deduplicating</td><td>πŸ”„ deduplication</td><td>MergeStrategyManager</td><td>-</td><td>0.01s</td></tr></table></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
@@ -160,11 +160,11 @@
"output_type": "stream",
"text": [
"Similarity between 'Apple Inc.' and 'Apple Inc':\n",
- " Total Score: 0.5592\n",
- " Breakdown: {'string': 0.9, 'property': 0.36410256410256414, 'relationship': 0.0}\n",
+ " Total Score: 0.7218\n",
+ " Breakdown: {'string': 0.98, 'property': 0.7728205128205129, 'relationship': 0.0}\n",
"\n",
"Similarity between 'Apple Inc.' and 'Microsoft':\n",
- " Total Score: 0.0400\n"
+ " Total Score: 0.1816\n"
]
}
],
@@ -213,7 +213,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Found 0 duplicate pairs:\n"
+ "Found 2 duplicate pairs:\n",
+ " - Microsoft Corp <==> Microsoft (Score: 0.80)\n",
+ " - Apple Inc. <==> Apple Inc (Score: 0.74)\n"
]
}
],
@@ -245,7 +247,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -277,15 +279,19 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Found 0 clusters:\n",
- "Found 0 clusters:\n"
+ "Found 2 clusters:\n",
+ " Cluster 1: ['Apple Inc.', 'Apple Inc']\n",
+ " Cluster 2: ['Microsoft Corp', 'Microsoft']\n",
+ "Found 2 clusters:\n",
+ " Cluster 1: ['Apple Inc.', 'Apple Inc']\n",
+ " Cluster 2: ['Microsoft Corp', 'Microsoft']\n"
]
}
],
@@ -325,7 +331,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -335,16 +341,22 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Performed 0 merge operations.\n",
+ "Performed 2 merge operations.\n",
"\n",
- "--- Merged Results ---\n"
+ "--- Merged Results ---\n",
+ "Merged 2 entities into: 'Microsoft Corp'\n",
+ " - Final Properties: {'industry': 'Software', 'hq': 'Redmond'}\n",
+ " - Final Relationships: 0\n",
+ "Merged 2 entities into: 'Apple Inc.'\n",
+ " - Final Properties: {'industry': 'Technology', 'hq': 'Cupertino', 'founded': 1976}\n",
+ " - Final Relationships: 1\n"
]
}
],
@@ -380,7 +392,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
@@ -391,14 +403,12 @@
"2. Merging entities...\n",
"\n",
"Original Size: 6\n",
- "Cleaned Size: 6\n",
+ "Cleaned Size: 4\n",
"\n",
"Final Entity Names:\n",
+ " - Microsoft Corp\n",
" - Apple Inc.\n",
- " - Apple Inc\n",
" - Apple\n",
- " - Microsoft Corp\n",
- " - Microsoft\n",
" - Google LLC\n"
]
}
@@ -416,11 +426,6 @@
" merger = EntityMerger()\n",
" ops = merger.merge_duplicates(raw_entities, strategy=MergeStrategy.KEEP_MOST_COMPLETE)\n",
" \n",
- " # Extract the final merged entities from the operations\n",
- " # Note: merge_duplicates returns operations for *merged* groups.\n",
- " # Entities that were not duplicated are often passed through or need to be collected.\n",
- " # In Semantica's EntityMerger, it typically returns the operations for the merges performed.\n",
- " \n",
" # Let's collect all final IDs to see what remains\n",
" merged_entities = [op.merged_entity for op in ops]\n",
" \n",