-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_basic.py
More file actions
80 lines (65 loc) · 2.71 KB
/
example_basic.py
File metadata and controls
80 lines (65 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""
ExisEcho API - Basic Example
This example demonstrates basic duplicate detection using the ExisEcho API.
Get your FREE test API key by emailing: exisllc@gmail.com
Documentation: https://www.fuzzy-logic.com/Api
"""
from exisecho import ExisEchoClient
# Replace with your API key
API_KEY = "your-api-key-here"
def main():
# Initialize the client
client = ExisEchoClient(API_KEY)
# Sample data with potential duplicates
records = [
{"id": "1", "fields": {"name": "John Smith", "email": "john.smith@example.com"}},
{"id": "2", "fields": {"name": "Jon Smyth", "email": "jon.smyth@example.com"}},
{"id": "3", "fields": {"name": "Jane Doe", "email": "jane.doe@example.com"}},
{"id": "4", "fields": {"name": "John A. Smith", "email": "johnsmith@example.com"}},
{"id": "5", "fields": {"name": "Robert Johnson", "email": "bob.johnson@example.com"}},
{"id": "6", "fields": {"name": "Bob Johnson", "email": "robert.j@example.com"}},
]
print("ExisEcho API - Basic Example")
print("=" * 50)
print()
print(f"Checking {len(records)} records for duplicates...")
print()
# Find duplicates with default settings
result = client.find_duplicates(
records=records,
threshold=0.7,
column_options={
"name": {
"usePhoneticMatching": True,
"equateSynonyms": True,
"ignoreWordOrder": True
}
}
)
if result["success"]:
summary = result["summary"]
print(f"Results:")
print(f" - Records analyzed: {summary['totalRecordsAnalyzed']}")
print(f" - Duplicates found: {summary['totalMatches']}")
print(f" - Processing time: {summary['processingTimeMs']}ms")
print()
if result["matches"]:
print("Potential Duplicates:")
print("-" * 50)
for match in result["matches"]:
# Find the original records for display
rec1 = next(r for r in records if r["id"] == match["record1Id"])
rec2 = next(r for r in records if r["id"] == match["record2Id"])
print(f" Match Score: {match['score']:.0%} ({match['quality']})")
print(f" Record {match['record1Id']}: {rec1['fields']['name']}")
print(f" Record {match['record2Id']}: {rec2['fields']['name']}")
print()
# Show usage info
usage = result["usage"]
print(f"API Usage:")
print(f" - Units consumed: {usage['unitsConsumed']}")
print(f" - Units remaining: {usage['unitsRemaining']}")
else:
print(f"Error: {result.get('error', 'Unknown error')}")
if __name__ == "__main__":
main()