c1v-id 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- c1v_id-0.1.0/.gitignore +42 -0
- c1v_id-0.1.0/LICENSE +21 -0
- c1v_id-0.1.0/PKG-INFO +219 -0
- c1v_id-0.1.0/README.md +185 -0
- c1v_id-0.1.0/pyproject.toml +81 -0
- c1v_id-0.1.0/src/c1v_id/__init__.py +107 -0
- c1v_id-0.1.0/src/c1v_id/blocking.py +221 -0
- c1v_id-0.1.0/src/c1v_id/clustering.py +159 -0
- c1v_id-0.1.0/src/c1v_id/config.py +130 -0
- c1v_id-0.1.0/src/c1v_id/golden.py +208 -0
- c1v_id-0.1.0/src/c1v_id/normalize.py +201 -0
- c1v_id-0.1.0/src/c1v_id/py.typed +0 -0
- c1v_id-0.1.0/src/c1v_id/resolver.py +419 -0
- c1v_id-0.1.0/src/c1v_id/scoring.py +166 -0
c1v_id-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
ENV/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# Testing
|
|
35
|
+
.coverage
|
|
36
|
+
.pytest_cache/
|
|
37
|
+
htmlcov/
|
|
38
|
+
.mypy_cache/
|
|
39
|
+
|
|
40
|
+
# OS
|
|
41
|
+
.DS_Store
|
|
42
|
+
Thumbs.db
|
c1v_id-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 David Ancor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
c1v_id-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: c1v-id
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Identity resolution for AI applications - resolve duplicates in 10 lines of Python
|
|
5
|
+
Project-URL: Homepage, https://github.com/davidancor/c1v-id
|
|
6
|
+
Project-URL: Documentation, https://github.com/davidancor/c1v-id#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/davidancor/c1v-id
|
|
8
|
+
Project-URL: Issues, https://github.com/davidancor/c1v-id/issues
|
|
9
|
+
Author: David Ancor
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,deduplication,entity-matching,golden-record,identity-resolution,langchain,mcp,record-linkage
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: pandas>=2.0.0
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Requires-Dist: rapidfuzz>=3.0.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# c1v-id
|
|
36
|
+
|
|
37
|
+
**Identity resolution for AI applications**
|
|
38
|
+
|
|
39
|
+
[](https://badge.fury.io/py/c1v-id)
|
|
40
|
+
[](https://www.python.org/downloads/)
|
|
41
|
+
[](https://opensource.org/licenses/MIT)
|
|
42
|
+
|
|
43
|
+
AI agents that interact with customers, CRMs, or any system of record face a critical decision point: *is this person already in our system, or should we create a new record?* Because both input and existing data are often messy, agents can confuse customer records, pollute data with duplicates, or deliver poor customer experiences.
|
|
44
|
+
|
|
45
|
+
**c1v-id** is an open-source identity resolution library that sits between the agent and the system of record, answering identity queries in milliseconds. It uses probabilistic record linkage with blocking strategies (~O(n) vs naive O(n²)), weighted multi-field scoring, and transitive clustering. Designed as a drop-in for LangChain agents, n8n workflows, and RAG pipelines. Zero ML dependencies. Configurable survivorship rules.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install c1v-id
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
Resolve duplicates in 10 lines of Python:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from c1v_id import IdentityResolver
|
|
59
|
+
|
|
60
|
+
resolver = IdentityResolver()
|
|
61
|
+
|
|
62
|
+
records = [
|
|
63
|
+
{"email": "john@gmail.com", "name": "John Doe", "phone": "555-1234"},
|
|
64
|
+
{"email": "john@gmail.com", "name": "J. Doe", "phone": "555-1234"},
|
|
65
|
+
{"email": "jane@gmail.com", "name": "Jane Smith"},
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
golden = resolver.resolve(records)
|
|
69
|
+
print(f"Input: {len(records)} records → Output: {len(golden)} golden records")
|
|
70
|
+
# Input: 3 records → Output: 2 golden records
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Match Two Records
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
result = resolver.match(
|
|
77
|
+
{"email": "john@gmail.com", "name": "John"},
|
|
78
|
+
{"email": "john@gmail.com", "name": "Johnny"}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
print(result.score) # 0.97
|
|
82
|
+
print(result.decision) # 'auto_merge'
|
|
83
|
+
print(result.matched_on) # ['email', 'name']
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Find Matches in Existing Data
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
incoming = {"email": "john@gmail.com", "name": "John"}
|
|
90
|
+
existing = [
|
|
91
|
+
{"id": "1", "email": "john@gmail.com", "name": "John Doe"},
|
|
92
|
+
{"id": "2", "email": "jane@gmail.com", "name": "Jane Doe"},
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
matches = resolver.find_matches(incoming, existing)
|
|
96
|
+
# Returns best matches sorted by score
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Custom Configuration
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from c1v_id import IdentityResolver, ResolverConfig, Thresholds, Weights
|
|
103
|
+
|
|
104
|
+
config = ResolverConfig(
|
|
105
|
+
thresholds=Thresholds(auto_merge=0.95, needs_review=0.8),
|
|
106
|
+
weights=Weights(email=0.6, phone=0.3, name=0.1, address=0.0),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
resolver = IdentityResolver(config=config)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Why c1v-id?
|
|
113
|
+
|
|
114
|
+
### vs. Splink
|
|
115
|
+
|
|
116
|
+
| | c1v-id | Splink |
|
|
117
|
+
|---|--------|--------|
|
|
118
|
+
| **Hello World** | 10 lines | 50+ lines |
|
|
119
|
+
| **Target** | AI builders | Data analysts |
|
|
120
|
+
| **Setup** | `pip install` | Spark/DuckDB config |
|
|
121
|
+
| **ML Required** | No | Optional |
|
|
122
|
+
| **Use Case** | Real-time matching | Batch analytics |
|
|
123
|
+
|
|
124
|
+
Splink is powerful for large-scale data linkage projects with dedicated analysts. c1v-id is for developers who need identity resolution as a feature, not a project.
|
|
125
|
+
|
|
126
|
+
### vs. dedupe
|
|
127
|
+
|
|
128
|
+
| | c1v-id | dedupe |
|
|
129
|
+
|---|--------|--------|
|
|
130
|
+
| **Maintenance** | Active | Stale (2+ years) |
|
|
131
|
+
| **Dependencies** | 3 (pandas, rapidfuzz, pyyaml) | 10+ |
|
|
132
|
+
| **Learning Curve** | Minimal | Requires training data |
|
|
133
|
+
| **API Style** | `resolve(records)` | Iterative labeling |
|
|
134
|
+
|
|
135
|
+
dedupe requires interactive labeling to train a model. c1v-id works out of the box with sensible defaults.
|
|
136
|
+
|
|
137
|
+
### vs. Enterprise CDPs (Segment, mParticle)
|
|
138
|
+
|
|
139
|
+
| | c1v-id | Enterprise CDP |
|
|
140
|
+
|---|--------|----------------|
|
|
141
|
+
| **Cost** | Free | $100K+/year |
|
|
142
|
+
| **Data Location** | Your infrastructure | Their cloud |
|
|
143
|
+
| **Customization** | Full control | Limited |
|
|
144
|
+
| **Integration** | Any Python app | Vendor lock-in |
|
|
145
|
+
|
|
146
|
+
Enterprise CDPs solve identity as part of a larger platform. c1v-id gives you just the identity resolution piece to embed anywhere.
|
|
147
|
+
|
|
148
|
+
## Core Concepts
|
|
149
|
+
|
|
150
|
+
| Concept | What It Does | Why It Matters |
|
|
151
|
+
|---------|--------------|----------------|
|
|
152
|
+
| **Normalization** | Cleans emails, phones, names | `John.Doe+tag@Gmail.com` → `johndoe@gmail.com` |
|
|
153
|
+
| **Blocking** | Groups likely matches | Reduces O(n²) to ~O(n) |
|
|
154
|
+
| **Scoring** | Calculates similarity | Weighted fuzzy matching across fields |
|
|
155
|
+
| **Clustering** | Groups transitive matches | If A≈B and B≈C, then A∈C |
|
|
156
|
+
| **Golden Records** | Merges duplicates | Best value wins per survivorship rules |
|
|
157
|
+
|
|
158
|
+
## Low-Level API
|
|
159
|
+
|
|
160
|
+
For custom pipelines, use the building blocks directly:
|
|
161
|
+
|
|
162
|
+
### Normalization
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from c1v_id import norm_email, norm_phone, norm_name
|
|
166
|
+
|
|
167
|
+
norm_email("John.Doe+tag@Gmail.com") # 'johndoe@gmail.com'
|
|
168
|
+
norm_phone("(555) 123-4567") # '5551234567'
|
|
169
|
+
norm_name(" JOHN DOE ") # 'john doe'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Blocking
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from c1v_id import email_domain_last4, phone_last7, make_blocks
|
|
176
|
+
|
|
177
|
+
email_domain_last4("john@gmail.com") # 'gmail.com|john'
|
|
178
|
+
phone_last7("555-123-4567") # '1234567'
|
|
179
|
+
|
|
180
|
+
blocks = make_blocks(df, ["email_domain_last4", "phone_last7"])
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Clustering
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from c1v_id import UnionFind
|
|
187
|
+
|
|
188
|
+
uf = UnionFind([1, 2, 3, 4, 5])
|
|
189
|
+
uf.union(1, 2)
|
|
190
|
+
uf.union(2, 3)
|
|
191
|
+
uf.find(1) == uf.find(3) # True (transitive)
|
|
192
|
+
uf.get_clusters() # {1: [1, 2, 3], 4: [4], 5: [5]}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Golden Records
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from c1v_id import build_golden_records, SurvivorshipRule
|
|
199
|
+
|
|
200
|
+
rules = {
|
|
201
|
+
"email": SurvivorshipRule.MOST_RECENT,
|
|
202
|
+
"address": SurvivorshipRule.LONGEST,
|
|
203
|
+
"first": SurvivorshipRule.FIRST_NON_NULL,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
golden = build_golden_records(df, clusters, rules, source_priority=["crm", "web"])
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Use Cases
|
|
210
|
+
|
|
211
|
+
- **AI Agents**: Check if a customer exists before creating a new record
|
|
212
|
+
- **CRM Deduplication**: Merge duplicate contacts from multiple sources
|
|
213
|
+
- **Lead Routing**: Match incoming leads to existing opportunities
|
|
214
|
+
- **Customer Support**: Find customer context across fragmented records
|
|
215
|
+
- **Data Migration**: Deduplicate when merging systems
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
MIT
|
c1v_id-0.1.0/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# c1v-id
|
|
2
|
+
|
|
3
|
+
**Identity resolution for AI applications**
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/py/c1v-id)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
AI agents that interact with customers, CRMs, or any system of record face a critical decision point: *is this person already in our system, or should we create a new record?* Because both input and existing data are often messy, agents can confuse customer records, pollute data with duplicates, or deliver poor customer experiences.
|
|
10
|
+
|
|
11
|
+
**c1v-id** is an open-source identity resolution library that sits between the agent and the system of record, answering identity queries in milliseconds. It uses probabilistic record linkage with blocking strategies (~O(n) vs naive O(n²)), weighted multi-field scoring, and transitive clustering. Designed as a drop-in for LangChain agents, n8n workflows, and RAG pipelines. Zero ML dependencies. Configurable survivorship rules.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install c1v-id
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
Resolve duplicates in 10 lines of Python:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from c1v_id import IdentityResolver
|
|
25
|
+
|
|
26
|
+
resolver = IdentityResolver()
|
|
27
|
+
|
|
28
|
+
records = [
|
|
29
|
+
{"email": "john@gmail.com", "name": "John Doe", "phone": "555-1234"},
|
|
30
|
+
{"email": "john@gmail.com", "name": "J. Doe", "phone": "555-1234"},
|
|
31
|
+
{"email": "jane@gmail.com", "name": "Jane Smith"},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
golden = resolver.resolve(records)
|
|
35
|
+
print(f"Input: {len(records)} records → Output: {len(golden)} golden records")
|
|
36
|
+
# Input: 3 records → Output: 2 golden records
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Match Two Records
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
result = resolver.match(
|
|
43
|
+
{"email": "john@gmail.com", "name": "John"},
|
|
44
|
+
{"email": "john@gmail.com", "name": "Johnny"}
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
print(result.score) # 0.97
|
|
48
|
+
print(result.decision) # 'auto_merge'
|
|
49
|
+
print(result.matched_on) # ['email', 'name']
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Find Matches in Existing Data
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
incoming = {"email": "john@gmail.com", "name": "John"}
|
|
56
|
+
existing = [
|
|
57
|
+
{"id": "1", "email": "john@gmail.com", "name": "John Doe"},
|
|
58
|
+
{"id": "2", "email": "jane@gmail.com", "name": "Jane Doe"},
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
matches = resolver.find_matches(incoming, existing)
|
|
62
|
+
# Returns best matches sorted by score
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Custom Configuration
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from c1v_id import IdentityResolver, ResolverConfig, Thresholds, Weights
|
|
69
|
+
|
|
70
|
+
config = ResolverConfig(
|
|
71
|
+
thresholds=Thresholds(auto_merge=0.95, needs_review=0.8),
|
|
72
|
+
weights=Weights(email=0.6, phone=0.3, name=0.1, address=0.0),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
resolver = IdentityResolver(config=config)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Why c1v-id?
|
|
79
|
+
|
|
80
|
+
### vs. Splink
|
|
81
|
+
|
|
82
|
+
| | c1v-id | Splink |
|
|
83
|
+
|---|--------|--------|
|
|
84
|
+
| **Hello World** | 10 lines | 50+ lines |
|
|
85
|
+
| **Target** | AI builders | Data analysts |
|
|
86
|
+
| **Setup** | `pip install` | Spark/DuckDB config |
|
|
87
|
+
| **ML Required** | No | Optional |
|
|
88
|
+
| **Use Case** | Real-time matching | Batch analytics |
|
|
89
|
+
|
|
90
|
+
Splink is powerful for large-scale data linkage projects with dedicated analysts. c1v-id is for developers who need identity resolution as a feature, not a project.
|
|
91
|
+
|
|
92
|
+
### vs. dedupe
|
|
93
|
+
|
|
94
|
+
| | c1v-id | dedupe |
|
|
95
|
+
|---|--------|--------|
|
|
96
|
+
| **Maintenance** | Active | Stale (2+ years) |
|
|
97
|
+
| **Dependencies** | 3 (pandas, rapidfuzz, pyyaml) | 10+ |
|
|
98
|
+
| **Learning Curve** | Minimal | Requires training data |
|
|
99
|
+
| **API Style** | `resolve(records)` | Iterative labeling |
|
|
100
|
+
|
|
101
|
+
dedupe requires interactive labeling to train a model. c1v-id works out of the box with sensible defaults.
|
|
102
|
+
|
|
103
|
+
### vs. Enterprise CDPs (Segment, mParticle)
|
|
104
|
+
|
|
105
|
+
| | c1v-id | Enterprise CDP |
|
|
106
|
+
|---|--------|----------------|
|
|
107
|
+
| **Cost** | Free | $100K+/year |
|
|
108
|
+
| **Data Location** | Your infrastructure | Their cloud |
|
|
109
|
+
| **Customization** | Full control | Limited |
|
|
110
|
+
| **Integration** | Any Python app | Vendor lock-in |
|
|
111
|
+
|
|
112
|
+
Enterprise CDPs solve identity as part of a larger platform. c1v-id gives you just the identity resolution piece to embed anywhere.
|
|
113
|
+
|
|
114
|
+
## Core Concepts
|
|
115
|
+
|
|
116
|
+
| Concept | What It Does | Why It Matters |
|
|
117
|
+
|---------|--------------|----------------|
|
|
118
|
+
| **Normalization** | Cleans emails, phones, names | `John.Doe+tag@Gmail.com` → `johndoe@gmail.com` |
|
|
119
|
+
| **Blocking** | Groups likely matches | Reduces O(n²) to ~O(n) |
|
|
120
|
+
| **Scoring** | Calculates similarity | Weighted fuzzy matching across fields |
|
|
121
|
+
| **Clustering** | Groups transitive matches | If A≈B and B≈C, then A∈C |
|
|
122
|
+
| **Golden Records** | Merges duplicates | Best value wins per survivorship rules |
|
|
123
|
+
|
|
124
|
+
## Low-Level API
|
|
125
|
+
|
|
126
|
+
For custom pipelines, use the building blocks directly:
|
|
127
|
+
|
|
128
|
+
### Normalization
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from c1v_id import norm_email, norm_phone, norm_name
|
|
132
|
+
|
|
133
|
+
norm_email("John.Doe+tag@Gmail.com") # 'johndoe@gmail.com'
|
|
134
|
+
norm_phone("(555) 123-4567") # '5551234567'
|
|
135
|
+
norm_name(" JOHN DOE ") # 'john doe'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Blocking
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from c1v_id import email_domain_last4, phone_last7, make_blocks
|
|
142
|
+
|
|
143
|
+
email_domain_last4("john@gmail.com") # 'gmail.com|john'
|
|
144
|
+
phone_last7("555-123-4567") # '1234567'
|
|
145
|
+
|
|
146
|
+
blocks = make_blocks(df, ["email_domain_last4", "phone_last7"])
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Clustering
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from c1v_id import UnionFind
|
|
153
|
+
|
|
154
|
+
uf = UnionFind([1, 2, 3, 4, 5])
|
|
155
|
+
uf.union(1, 2)
|
|
156
|
+
uf.union(2, 3)
|
|
157
|
+
uf.find(1) == uf.find(3) # True (transitive)
|
|
158
|
+
uf.get_clusters() # {1: [1, 2, 3], 4: [4], 5: [5]}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Golden Records
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from c1v_id import build_golden_records, SurvivorshipRule
|
|
165
|
+
|
|
166
|
+
rules = {
|
|
167
|
+
"email": SurvivorshipRule.MOST_RECENT,
|
|
168
|
+
"address": SurvivorshipRule.LONGEST,
|
|
169
|
+
"first": SurvivorshipRule.FIRST_NON_NULL,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
golden = build_golden_records(df, clusters, rules, source_priority=["crm", "web"])
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Use Cases
|
|
176
|
+
|
|
177
|
+
- **AI Agents**: Check if a customer exists before creating a new record
|
|
178
|
+
- **CRM Deduplication**: Merge duplicate contacts from multiple sources
|
|
179
|
+
- **Lead Routing**: Match incoming leads to existing opportunities
|
|
180
|
+
- **Customer Support**: Find customer context across fragmented records
|
|
181
|
+
- **Data Migration**: Deduplicate when merging systems
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
MIT
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "c1v-id"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Identity resolution for AI applications - resolve duplicates in 10 lines of Python"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "David Ancor" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"identity-resolution",
|
|
17
|
+
"entity-matching",
|
|
18
|
+
"record-linkage",
|
|
19
|
+
"deduplication",
|
|
20
|
+
"golden-record",
|
|
21
|
+
"ai",
|
|
22
|
+
"langchain",
|
|
23
|
+
"mcp"
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 3 - Alpha",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"License :: OSI Approved :: MIT License",
|
|
29
|
+
"Operating System :: OS Independent",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
36
|
+
"Typing :: Typed",
|
|
37
|
+
]
|
|
38
|
+
dependencies = [
|
|
39
|
+
"pandas>=2.0.0",
|
|
40
|
+
"rapidfuzz>=3.0.0",
|
|
41
|
+
"pyyaml>=6.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.optional-dependencies]
|
|
45
|
+
dev = [
|
|
46
|
+
"pytest>=7.0.0",
|
|
47
|
+
"pytest-cov>=4.0.0",
|
|
48
|
+
"mypy>=1.0.0",
|
|
49
|
+
"ruff>=0.1.0",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.urls]
|
|
53
|
+
Homepage = "https://github.com/davidancor/c1v-id"
|
|
54
|
+
Documentation = "https://github.com/davidancor/c1v-id#readme"
|
|
55
|
+
Repository = "https://github.com/davidancor/c1v-id"
|
|
56
|
+
Issues = "https://github.com/davidancor/c1v-id/issues"
|
|
57
|
+
|
|
58
|
+
[tool.hatch.build.targets.sdist]
|
|
59
|
+
include = [
|
|
60
|
+
"/src",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.hatch.build.targets.wheel]
|
|
64
|
+
packages = ["src/c1v_id"]
|
|
65
|
+
|
|
66
|
+
[tool.mypy]
|
|
67
|
+
python_version = "3.10"
|
|
68
|
+
strict = true
|
|
69
|
+
warn_return_any = true
|
|
70
|
+
warn_unused_configs = true
|
|
71
|
+
|
|
72
|
+
[tool.ruff]
|
|
73
|
+
target-version = "py310"
|
|
74
|
+
line-length = 100
|
|
75
|
+
|
|
76
|
+
[tool.ruff.lint]
|
|
77
|
+
select = ["E", "F", "I", "UP", "B", "SIM"]
|
|
78
|
+
|
|
79
|
+
[tool.pytest.ini_options]
|
|
80
|
+
testpaths = ["tests"]
|
|
81
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""
|
|
2
|
+
c1v-id: Identity resolution for AI applications.
|
|
3
|
+
|
|
4
|
+
Resolve duplicate records into unified golden records in 10 lines of Python.
|
|
5
|
+
|
|
6
|
+
Quick example:
|
|
7
|
+
>>> from c1v_id import IdentityResolver
|
|
8
|
+
>>> resolver = IdentityResolver()
|
|
9
|
+
>>> records = [
|
|
10
|
+
... {"email": "john@gmail.com", "name": "John Doe"},
|
|
11
|
+
... {"email": "john@gmail.com", "name": "J. Doe"},
|
|
12
|
+
... ]
|
|
13
|
+
>>> golden = resolver.resolve(records)
|
|
14
|
+
>>> len(golden)
|
|
15
|
+
1
|
|
16
|
+
|
|
17
|
+
Match two records:
|
|
18
|
+
>>> result = resolver.match(
|
|
19
|
+
... {"email": "john@gmail.com", "name": "John"},
|
|
20
|
+
... {"email": "john@gmail.com", "name": "Johnny"}
|
|
21
|
+
... )
|
|
22
|
+
>>> result.score, result.decision
|
|
23
|
+
(0.95, 'auto_merge')
|
|
24
|
+
|
|
25
|
+
Low-level functions are also available for custom pipelines.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
__version__ = "0.1.0"
|
|
29
|
+
|
|
30
|
+
# High-level API (recommended)
|
|
31
|
+
# Blocking strategies
|
|
32
|
+
from c1v_id.blocking import (
|
|
33
|
+
email_domain_last4,
|
|
34
|
+
email_exact,
|
|
35
|
+
generate_pairs,
|
|
36
|
+
make_blocks,
|
|
37
|
+
name_fsa,
|
|
38
|
+
phone_last7,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Clustering
|
|
42
|
+
from c1v_id.clustering import (
|
|
43
|
+
UnionFind,
|
|
44
|
+
cluster_records,
|
|
45
|
+
)
|
|
46
|
+
from c1v_id.config import ResolverConfig, Thresholds, Weights
|
|
47
|
+
|
|
48
|
+
# Golden records
|
|
49
|
+
from c1v_id.golden import (
|
|
50
|
+
DEFAULT_SURVIVORSHIP_RULES,
|
|
51
|
+
SurvivorshipRule,
|
|
52
|
+
build_golden_records,
|
|
53
|
+
survivorship,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# Normalization functions
|
|
57
|
+
from c1v_id.normalize import (
|
|
58
|
+
fsa,
|
|
59
|
+
norm_address,
|
|
60
|
+
norm_email,
|
|
61
|
+
norm_name,
|
|
62
|
+
norm_phone,
|
|
63
|
+
)
|
|
64
|
+
from c1v_id.resolver import IdentityResolver, MatchResult
|
|
65
|
+
|
|
66
|
+
# Scoring functions
|
|
67
|
+
from c1v_id.scoring import (
|
|
68
|
+
exact_match,
|
|
69
|
+
fuzzy_score,
|
|
70
|
+
score_pair,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
__all__ = [
|
|
74
|
+
# Version
|
|
75
|
+
"__version__",
|
|
76
|
+
# High-level API
|
|
77
|
+
"IdentityResolver",
|
|
78
|
+
"MatchResult",
|
|
79
|
+
"ResolverConfig",
|
|
80
|
+
"Thresholds",
|
|
81
|
+
"Weights",
|
|
82
|
+
# Normalization
|
|
83
|
+
"norm_email",
|
|
84
|
+
"norm_phone",
|
|
85
|
+
"norm_name",
|
|
86
|
+
"norm_address",
|
|
87
|
+
"fsa",
|
|
88
|
+
# Blocking
|
|
89
|
+
"email_domain_last4",
|
|
90
|
+
"phone_last7",
|
|
91
|
+
"name_fsa",
|
|
92
|
+
"email_exact",
|
|
93
|
+
"make_blocks",
|
|
94
|
+
"generate_pairs",
|
|
95
|
+
# Scoring
|
|
96
|
+
"exact_match",
|
|
97
|
+
"fuzzy_score",
|
|
98
|
+
"score_pair",
|
|
99
|
+
# Clustering
|
|
100
|
+
"UnionFind",
|
|
101
|
+
"cluster_records",
|
|
102
|
+
# Golden records
|
|
103
|
+
"SurvivorshipRule",
|
|
104
|
+
"survivorship",
|
|
105
|
+
"build_golden_records",
|
|
106
|
+
"DEFAULT_SURVIVORSHIP_RULES",
|
|
107
|
+
]
|