Skip to main content

destiny-deduper

A suite of tools for deduplicating citatations for publications.

tl, dr

In large repositories of published works, we want to ensure that a given citation is not a duplicate of another. Hence the goal of this destiny-deduper is to provide a set of portable, customisable solutions for quantifying the likelihood that a given citation is a duplicate of another.

Installing destiny-deduper

If you just want to use destiny-deduper, you can install using pip:

pip install destiny-deduper

uv is often preferred over vanilla pip:

uv add destiny-deduper

Developer install

If you want to contribute to destiny-deduper, follow the following steps:

  1. Install uv

uv is used for dependency management and managing virtual environments. You can install uv either using pipx or the uv installer script:

curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Install project & dependencies

Once uv is installed, install dependencies:

uv sync
  1. Optional - activate your environment
source .venv/bin/activate

Using destiny-deduper

destiny-deduper was built with the priority of using it to run as a constant background job on citations stored in destiny-repository which may be duplicates of one another. Hence, this library may feature certain design decisions which mean it doesn't necessarily lend itself to your (local, or otherwise) use case. However, you can do a lot with what's here!

Using destiny References

from uuid import uuid4

from destiny_sdk.identifiers import DOIIdentifier, ExternalIdentifierType
from destiny_sdk.references import Reference

from destiny_deduper.data_models import convert_ref_to_paper
from destiny_deduper.dedupe import Deduper

ref_a = Reference(
    id=str(uuid4()),
    identifiers=[
        DOIIdentifier(
            identifier="10.1000/xyz123",
            identifier_type=ExternalIdentifierType.DOI,
        )
    ],
    enhancements=[],
)

ref_b = Reference(
    id=str(uuid4()),
    identifiers=[
        DOIIdentifier(
            identifier="10.1000/xyz123",
            identifier_type=ExternalIdentifierType.DOI,
        )
    ],
    enhancements=[],
)

paper_a = convert_ref_to_paper(ref_a)
paper_b = convert_ref_to_paper(ref_b)

deduper = Deduper(reference=paper_a, candidates=[paper_b])
probability = deduper.dedupe_weighted(paper_a, paper_b)

print(probability)

Using citations imported from csv

from destiny_deduper.algorithm.import_references import (
    CsvLoadConfig,
    load_reference_csv,
)
from destiny_deduper.dedupe import Deduper

papers = load_reference_csv(
    "records.csv",
    CsvLoadConfig(include_record_id=True),
)

paper_a = papers[0]
paper_b = papers[1]

deduper = Deduper(reference=paper_a, candidates=[paper_b])
result = deduper.score_pair(paper_a, paper_b)

print(result.probability)
print(result.label)

How we got here

Please see all the code in destiny_deduper/algorithm/, as well as notebooks for more info on the underlying research and study that went into developing the algorithm, thresholds and weights underlying destiny-deduper. You can also read deduplication_workflows.md for more info.

Contributing

If you want to contribute to this project -- awesome, everyone's welcome. Please see the contributing guidelines for details on how best to contribute.

A few important steps when contributing:

uv run pre-commit install --hook-type commit-msg

This will force you to use conventional commits.

Commit message format

All commits must use conventional commits. The pre-commit hook will reject any commit that doesn't.

prefix example version effect
fix: fix: handle null input patch: 0.1.0 -> 0.1.1
feat: feat: add login page minor: 0.1.0 -> 0.2.0
feat!: or BREAKING CHANGE: footer feat!: remove legacy api major: 0.1.0 -> 1.0.0
chore:, docs:, ci:, test: chore: update deps no bump

Release flow

sequenceDiagram
    participant Dev
    participant Main as main branch
    participant Release as Release workflow
    participant Publish as Publish workflow
    participant Test as TestPyPI
    participant PyPI as PyPI

    Dev->>Main: push conventional commit (feat:/fix:)
    Main->>Release: triggers (push to main)
    Release->>Release: semantic-release version<br/>bumps pyproject.toml, commits, tags, pushes
    Release->>Publish: triggers via workflow_run (on completion)
    Publish->>Publish: build job checks HEAD is tagged, uv build
    Publish->>Test: uv publish --index testpypi (OIDC)
    Test-->>Publish: success
    Publish->>PyPI: uv publish (OIDC)
    PyPI-->>Publish: success

Metadata

Release files for destiny-deduper 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for destiny-deduper 0.2.7
File Size Uploaded
destiny_deduper-0.2.7.tar.gz 52.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for destiny-deduper 0.2.7
File Interpreter ABI Platform
destiny_deduper-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 102.2 kB

Release files / destiny_deduper-0.2.7.tar.gz

Download URL destiny_deduper-0.2.7.tar.gz
Size 52.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9f7c5b938b8ddfbd12cd1a30bc61bbd975dd3ffcab8336266fca7846a189b65f
BLAKE2b-256 checksum
How to use checksums
25ae65d010ced17b00f1ec019205cc4110b512834e0c4c9a1cb25260bc2f1744
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / destiny_deduper-0.2.7-py3-none-any.whl

Download URL destiny_deduper-0.2.7-py3-none-any.whl
Size 49.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c35acb1c5e514a3f02a6804ed68e18e98249e1edcb8d9a69bd177a3b016306b
BLAKE2b-256 checksum
How to use checksums
228d970b5b45ebab033307b45d468afd0009d567838417aee9207fa25631a224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page