Skip to main content

CanonMap - A Python library for entity canonicalization and mapping

Project description

CanonMap

CanonMap is a Python library for generating and managing canonical entity artifacts from various data sources. It provides a streamlined interface for processing data files and generating standardized artifacts that can be used for entity matching and data integration.

Features

  • Flexible Input Support: Process data from:

    • CSV/JSON files
    • Directories of data files
    • Pandas DataFrames
    • Python dictionaries
  • Artifact Generation:

    • Generate canonical entity lists
    • Create database schemas (supports multiple database types)
    • Generate semantic embeddings for entities
    • Clean and standardize field names
    • Process metadata fields
  • Database Support:

    • DuckDB (default)
    • SQLite
    • BigQuery
    • MariaDB
    • MySQL
    • PostgreSQL

Installation

pip install canonmap

Quick Start

from canonmap import CanonMap
from canonmap.models.artifact_generation_request import ArtifactGenerationRequest, EntityField

# Initialize CanonMap
canonmap = CanonMap()

# Configure artifact generation
config = ArtifactGenerationRequest(
    input_path="path/to/your/data.csv",
    output_path="path/to/output",
    source_name="my_source",
    table_name="my_table",
    entity_fields=[
        EntityField(table_name="my_table", field_name="name"),
        EntityField(table_name="my_table", field_name="id")
    ],
    semantic_fields=["description", "notes"],
    generate_schema=True,
    generate_embeddings=True
)

# Generate artifacts
results = canonmap.generate(config)

Configuration Options

The ArtifactGenerationRequest model provides extensive configuration options:

  • Input/Output:

    • input_path: Path to data file/directory or DataFrame/dict
    • output_path: Directory for generated artifacts
    • source_name: Logical source name
    • table_name: Logical table name
  • Directory Processing:

    • recursive: Process subdirectories
    • file_pattern: File matching pattern (e.g., "*.csv")
    • table_name_from_file: Use filename as table name
  • Entity Processing:

    • entity_fields: List of fields to treat as entities
    • semantic_fields: Fields for semantic embeddings
    • use_other_fields_as_metadata: Include non-entity fields as metadata
  • Generation Options:

    • generate_canonical_entities: Generate entity list
    • generate_schema: Generate database schema
    • generate_embeddings: Generate semantic embeddings
    • save_processed_data: Save cleaned data
    • schema_database_type: Target database type
    • clean_field_names: Standardize field names

Output

The generate() method returns a dictionary containing:

  • Generated artifacts
  • Paths to saved files
  • Schema information (if requested)
  • Embeddings (if requested)
  • Processed data (if requested)

Contributing

Contributions 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


Release history Release notifications | RSS feed

Download files

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

Source Distribution

canonmap-0.1.139.tar.gz (35.8 kB view details)

Uploaded Source

Built Distribution

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

canonmap-0.1.139-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file canonmap-0.1.139.tar.gz.

File metadata

  • Download URL: canonmap-0.1.139.tar.gz
  • Upload date:
  • Size: 35.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for canonmap-0.1.139.tar.gz
Algorithm Hash digest
SHA256 a0d5735314fdc5f1c15728aa47305a02c79f1611c6d9bd5ec6c752b8d11d01ab
MD5 f821c3064cd82447b76010f1d4196f2e
BLAKE2b-256 6d06ec018d6d340a982d0005a786b6cfefea3c2c5b6794947466132ff7eb099f

See more details on using hashes here.

File details

Details for the file canonmap-0.1.139-py3-none-any.whl.

File metadata

  • Download URL: canonmap-0.1.139-py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for canonmap-0.1.139-py3-none-any.whl
Algorithm Hash digest
SHA256 82d3e40b49d0ef1dd502d4a1bb0f440ebe1154b3c9a5d9c38c6d05589b0d32e0
MD5 a94bfe3a06a72349045162b167457c99
BLAKE2b-256 b91fa5f6c06ffb103cf6f4368d92ee2a537679a9fda7afc4d2931adadd1011e9

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