🧹 gibsondedup
High‑Performance Search Result Deduplication Engine
📌 The Problem
When aggregating search results from multiple providers (Google, Bing, DuckDuckGo), 40–60% of results are duplicates — same content, different URLs, different titles, different tracking parameters.
Source 1 (Google):
url: https://www.python.org/docs?utm_source=google
title: "Python Official Documentation"
Source 2 (Bing):
url: http://python.org/docs/
title: "Python Docs"
Source 3 (DuckDuckGo):
url: https://python.org/docs?utm_medium=cpc
title: "Learn Python - Official Docs"
These are the same resource. Without deduplication, users see noise instead of signal.
✨ The Solution
gibsondedup processes raw search results through a multi‑stage pipeline:
flowchart TD
A[Raw Results] --> B[Parse & Validate]
B --> C[URL Normalization]
C --> D[Exact URL Grouping]
D --> E[Semantic Merge]
E --> F[Canonicalization]
F --> G[Clean Output + Metadata]
Result: 100 noisy inputs → 60–70 clean, canonical results.
🚀 Installation
pip install gibsondedup
🏃 Quick Start
from gibsondedup import DeduplicationEngine
engine = DeduplicationEngine()
results = engine.process([
{
"title": "Python Official Documentation",
"url": "https://www.python.org/docs?utm_source=google",
"description": "Official Python docs",
"source": "google"
},
{
"title": "Python Docs",
"url": "http://python.org/docs/",
"description": "Python documentation",
"source": "bing"
},
{
"title": "Stack Overflow Python",
"url": "https://stackoverflow.com/questions/tagged/python",
"description": "Python questions",
"source": "google"
},
])
print(results)
Output:
{
"results": [
{
"title": "Python Official Documentation",
"url": "https://www.python.org/docs?utm_source=google",
"canonical_url": "python.org/docs",
"description": "Official Python docs",
"sources": ["google", "bing"],
"duplicates_removed": 1
},
{
"title": "Stack Overflow Python",
"url": "https://stackoverflow.com/questions/tagged/python",
"canonical_url": "stackoverflow.com/questions/tagged/python",
"description": "Python questions",
"sources": ["google"],
"duplicates_removed": 0
}
],
"meta": {
"total_input": 3,
"total_parsed": 3,
"total_output": 2,
"duplicates_removed": 1,
"processing_time_ms": 0.09,
"similarity_threshold": 0.8
}
}
⚙️ Configuration
Custom Similarity Threshold
Control how aggressively similar‑titled results are merged:
# Conservative (default) — only merge highly similar titles
engine = DeduplicationEngine(similarity_threshold=0.8)
# Moderate — merge titles with moderate overlap
engine = DeduplicationEngine(similarity_threshold=0.5)
# Aggressive — merge titles with minimal overlap
engine = DeduplicationEngine(similarity_threshold=0.3)
Input Contract
| Field | Type | Required | Description |
|---|---|---|---|
title |
string | ✅ | Result title |
url |
string | ✅ | Result URL |
description |
string | ❌ | Result description |
source |
string | ❌ | Source provider (google, bing, etc.) |
Note: Malformed records (missing title or URL) are skipped gracefully — the pipeline continues processing valid records.
🧱 Architecture
Pipeline Stages
| Stage | Description |
|---|---|
| 1. Parser | Converts raw JSON payloads into structured internal contracts. Validates required fields. Skips malformed records without crashing. |
| 2. URL Normalizer | Converts URLs to canonical form by removing protocol, www, tracking params (utm_*, fbclid, gclid), trailing slashes, default ports, and lowercasing everything. |
| 3. Exact Grouping | Groups results by normalized canonical URL using a hash map. O(n) complexity – avoids O(n²) pairwise comparison. |
| 4. Semantic Merger | Within groups sharing the same domain, compares titles using Jaccard similarity. Groups exceeding threshold are merged. Only compares within the same exact domain. |
| 5. Canonicalizer | Selects the single best result per group using a combined title+description length heuristic. Collects source traceability from all merged results. |
Data Contracts
# Input
RawSearchResult(title, url, description?, source?)
# Internal
NormalizedSearchResult(title, url, canonical_url, description, source)
# Output
CanonicalResult(title, url, canonical_url, description, sources[], duplicates_removed)
System Invariants
- Same normalized URL → same duplicate group (always)
- Canonical results preserve source traceability (always)
- Pipeline stages do not mutate upstream data (always)
- Normalization happens once per result (always)
🧠 Engineering Decisions
| Question | Answer |
|---|---|
| Why hash‑based grouping (O(n)) over pairwise (O(n²))? | With 1000 results, O(n²) → 1M comparisons. O(n) → 1000. Milliseconds vs seconds. |
| Why exact domain matching for semantic merging? | python.org/docs and docs.python.org serve different content. Exact domain prevents false merges. |
| Why Jaccard similarity over Levenshtein distance? | Jaccard operates on word tokens – robust to word order changes & additions. Levenshtein is sensitive to trivial differences like "Docs" vs "Documentation". |
| Why keep normalization deterministic? | Same input → same output. Enables reproducible runs, safe caching, reliable tests. |
📊 Performance
| Input Size | Processing Time | Memory |
|---|---|---|
| 100 results | ~1ms | ~1MB |
| 1,000 results | ~10ms | ~5MB |
| 10,000 results | ~100ms | ~50MB |
Benchmarked on Ubuntu 22.04, Python 3.10, Intel i5
🧪 Testing
# Install dev dependencies
pip install pytest pytest-cov
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=app --cov-report=term-missing
Test coverage: 59 tests across 5 modules
| Module | Tests | Focus |
|---|---|---|
test_normalizer.py |
14 | URL normalization |
test_grouping.py |
4 | Exact grouping |
test_canonicalizer.py |
7 | Best result selection |
test_merger.py |
11 | Semantic merging |
test_similarity.py |
13 | Jaccard similarity |
test_pipeline.py |
10 | End‑to‑end pipeline |
🗺️ Roadmap
| Phase | Status | Features |
|---|---|---|
| Phase 1 | ✅ Complete | URL normalization, exact duplicate grouping, canonicalization with source traceability |
| Phase 2 | ✅ Complete | Jaccard similarity engine, domain‑based semantic merging, configurable threshold |
| Phase 3 | 🚧 Planned | Persistent caching (Redis), database storage (PostgreSQL), REST API, Rails wrapper |
| Phase 4 | 🔮 Planned | Semantic embeddings (vector similarity), distributed processing, production observability |
📄 License
MIT License. See LICENSE file.
👤 Author
Aseda Gibson
Computer Engineering, University of Energy and Natural Resources (UENR), Ghana.
Backend systems, distributed architecture, infrastructure tooling.
Every architectural decision is documented. Every invariant is tested.
Metadata
Release files for gibsondedup 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gibsondedup-0.1.1.tar.gz | 17.3 kB | Without provenance | Details for gibsondedup-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gibsondedup-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for gibsondedup-0.1.1-py3-none-any.whl |
Total release size: 36.2 kB
Release files / gibsondedup-0.1.1.tar.gz
| Download URL | gibsondedup-0.1.1.tar.gz |
|---|---|
| Size | 17.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e381d82973780204eabf6495254b166176060ef6af8a98fe2886ebb00f4b0c95
|
|
BLAKE2b-256 checksum How to use checksums |
469e4ec86800e16e39d317a7542797dba0afbaff3695cd3f3e2f65ee9489b786
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / gibsondedup-0.1.1-py3-none-any.whl
| Download URL | gibsondedup-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9b1aebfa4b9fd7f51600ca1513412c4228d94d50049adcee0682629ce0b0162
|
|
BLAKE2b-256 checksum How to use checksums |
4a0a24bacc3663b3f9b925f5b367f6f9edec69b2d9aa2d7492000dfaad44a559
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for gibsondedup 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.