Skip to main content

Entity resolution for everyone. Minimal. No dependencies.

Project description

rezolva

Entity resolution for everyone. Minimal. No dependencies.

rezolva is a lightweight, flexible, and extensible entity resolution library implemented in pure Python. It's designed for simplicity, educational purposes, and easy integration into larger projects. (it is also very much a work in progress)

Features

  • Zero dependencies: built with Python standard library only
  • Modular architecture: easy to customize and extend
  • Defaults: out-of-the-box implementations of ER algorithms
  • Flexible: adaptable to various ER scenarios
  • Evaluation: utilities for testing precision, recall, F1, accuracy
  • Visualization: trace candidates through the resolution process

Installation

pip install rezolva

Quick Start

Here's a simple example of how to use rezolva:

from rezolva import Entity, EntityResolver, SimpleBlocker, SimpleModelBuilder, SimplePreprocessor
from rezolva.matchers import CosineSimilarityMatcher
from rezolva.preprocessors.preprocessing_functions import lowercase, strip_whitespace, remove_punctuation

# Set up components
preprocessor = SimplePreprocessor([lowercase, strip_whitespace, remove_punctuation])
model_builder = SimpleModelBuilder(['title', 'description', 'brand'])
matcher = CosineSimilarityMatcher(threshold=0.5, attribute_weights={'title': 2.0, 'description': 1.5, 'brand': 1.0})
blocker = SimpleBlocker(lambda e: e.attributes['brand'].lower())

# Create resolver
resolver = EntityResolver(preprocessor, model_builder, matcher, blocker)

# Train the resolver
training_entities = [
    Entity("1", {"title": "iPhone 12", "description": "Latest Apple smartphone", "brand": "Apple"}),
    Entity("2", {"title": "Galaxy S21", "description": "Samsung's flagship phone", "brand": "Samsung"}),
    Entity("3", {"title": "Pixel 5", "description": "Google's latest smartphone", "brand": "Google"}),
]
resolver.train(training_entities)

# Resolve new entities
new_entities = [
    Entity("4", {"title": "iPhone 12 Pro", "description": "Apple's premium smartphone", "brand": "Apple"}),
    Entity("5", {"title": "Galaxy S21+", "description": "Samsung's large screen flagship", "brand": "Samsung"}),
]
results = resolver.resolve(new_entities, top_k=1)

# Print results
for entity, matches in results:
    print(f"Top matches for {entity.id} - {entity.attributes['title']}:")
    for match, score in matches[:2]:
        print(f"  Match: {match.id} - {match.attributes['title']} (Score: {score:.2f})")

Advanced Usage

For more advanced examples, including custom preprocessing, different matching algorithms, model saving/loading, deduplication, and more, please check the examples directory in the repository.

Customization

You can extend rezolva by creating custom implementations of its components:

  1. Subclass the base component classes (Preprocessor, ModelBuilder, Matcher, Blocker)
  2. Implement the required methods with your custom logic
  3. Use your custom components when creating the EntityResolver

Contributing

Contributions to rezolva are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rezolva-0.2.2.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rezolva-0.2.2-py3-none-any.whl (67.8 kB view details)

Uploaded Python 3

File details

Details for the file rezolva-0.2.2.tar.gz.

File metadata

  • Download URL: rezolva-0.2.2.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for rezolva-0.2.2.tar.gz
Algorithm Hash digest
SHA256 192bd8b7e3500bf9ba937083f0aeb4a448b0a8f19bca17b0b5efdc54e031374b
MD5 0cf5d1af363000ac908502ad6e5575dc
BLAKE2b-256 b68c24b2ff29d5d4083993fb3b3001efe1ca5ac303c9de0b37ce553bb6e91dfc

See more details on using hashes here.

File details

Details for the file rezolva-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: rezolva-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 67.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for rezolva-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 359f0747ebe6868b35d7a875437cc6acaa37b1deff0346dd2f5e7b3a46b6dba8
MD5 a848983cfaff94f7ff31a374ba049498
BLAKE2b-256 66878b2f80c6e45824f4dc61a7bc88940e03e4a168d1a6e4ace080af05206b37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page