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.6

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.6
File Size Uploaded
destiny_deduper-0.2.6.tar.gz 52.7 kB Details

Built distribution (wheel)

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

Total release size: 102.1 kB

Release files / destiny_deduper-0.2.6.tar.gz

Download URL destiny_deduper-0.2.6.tar.gz
Size 52.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e9319b19caa00533c558245570a121fb0c7a2e5e6154cd156f272d56648f77a8
BLAKE2b-256 checksum
How to use checksums
1495eeff06d26d35f6b3f803337898f242ffd443e52f172d418bde5517a5e43a
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.6-py3-none-any.whl

Download URL destiny_deduper-0.2.6-py3-none-any.whl
Size 49.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b19d4c39dcbd3f6a4a2123a0436eee1cb6ea33b6ecc0e4420b21bbba79095340
BLAKE2b-256 checksum
How to use checksums
91bf22f1f287bc2ae9bfe08acceec62311d79db43915380a8c8ff711d2a0d4d7
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

0.2.7

2 release files

This release

0.2.6 This release

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