Skip to main content

meddeid-core

meddeid-core provides the language-neutral contracts shared by the MedDeID suite: the document schema, 15-label data taxonomy, ordered 14-label model head, record normalization, and character-offset validation.

The suite documentation explains how this contract moves through MedDeID workflows. This repository is the authority for the schema, taxonomy, label order, and offset rules.

Installation

pip install meddeid-core

Install the optional Pydantic models with:

pip install 'meddeid-core[models]'

Python API

from meddeid_core import BERT_ENTITY_LABELS, normalize_record, validate_record

record = normalize_record(record)
validate_record(record)

MedDeID uses half-open [begin, end) offsets measured in Unicode code points. The only canonical top-level span container is spans.

The core package also owns the language-neutral meddeid.age-granularity.v1 JSON contract. load_age_granularity_policy() loads the packaged default, a custom JSON path, or a mapping and returns its validated calendar generalizer and deterministic identity. Language packages remain responsible only for parsing and localized rendering.

Benchmark subannotations are nested under their parent primary span. A non-empty subannotation list must be a complete, contiguous partition of the parent, and all offsets remain absolute document offsets:

{
  "begin": 0,
  "end": 11,
  "text": "Jan Peeters",
  "label": "Name:Patient",
  "category": "Name",
  "subtype": "Patient",
  "subannotations": [
    {"begin": 0, "end": 3, "text": "Jan", "category": "given"},
    {"begin": 3, "end": 4, "text": " ", "category": "formatting"},
    {"begin": 4, "end": 11, "text": "Peeters", "category": "family"}
  ]
}

Name replacement contract

For HTTP inference, use render.name_replacement with a patient scope. The gateway supplies the mapping key. A CPU job can pass the same scope and key to meddeid_core.rendering.apply_spans. The canonical JSONL metadata normalizer also accepts a strict Boolean name_replacement field. Rendering guide

Core provides meddeid.name-components.v2 in meddeid_core.name_components. A language pack supplies lookup lists and recognized titles. Each normalized name component has its own keyed alias, with a common keyed initial mapping. This keeps full names, middle names, initials and individual components consistent. The original v1 digest remains available for reproducing older exports.

configuration() requires a secret of at least 32 bytes and a nonempty study scope. scoped_settings(settings, "patient", patient_id) derives a patient-specific key within that study. Use "study" for deliberate cross-patient linkage. Keys stay in deployment configuration. Shared components remain linkable within a scope and finite aliases can collide.

Normalize canonical JSONL

The normalizer standardizes fields within records that use the canonical document_id, text, and spans containers. For example, it can convert start to begin:

meddeid-normalize-jsonl input.jsonl normalized.jsonl

Other top-level span containers, including annotations, entities, deid_spans, and items, are not part of the MedDeID schema and are rejected.

Taxonomy contract

The Python taxonomy is authoritative. The generated language-neutral contract is committed at contracts/taxonomy.json for JavaScript and non-Python consumers. After an intentional taxonomy change, regenerate it with:

python scripts/export_contracts.py

Language-specific behavior belongs in packages such as meddeid-language-nl; this package has no language rules or model runtime.

Development

pip install -e '.[dev]'
pytest

Licence

AGPL-3.0-only. See NOTICE for attribution information.

Render previously detected spans on CPU

meddeid_core.rendering.apply_spans(text, spans, ...) renders offsets in the original Unicode text. The default replaces detected identifiers with labels. Names, clinical ages and event dates can be enabled independently. Install the matching Dutch or English language package for locale-specific rendering. PseudonymizationScope, pseudonymize_name and derive_date_offset use the same mapping for free text and structured values. Treat the mapping key and the derived offset as sensitive. Keep the key, language resources and algorithm version fixed to reproduce an export.

HTTP clients and data pipelines

Use meddeid_core.client.GatewayClient to call the inference service and meddeid_core.rendering.apply_spans to render further variants on CPU. For stored detections, meddeid_core.pipeline.create_annotation_record binds the response to your JSON source reference. On a later run pass the independently selected row reference and exact text to meddeid_core.pipeline.read_spans.

Metadata

Release files for meddeid-core 0.2.4

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

Source distribution (sdist)

Source distribution for meddeid-core 0.2.4
File Size Uploaded Provenance Actions
meddeid_core-0.2.4.tar.gz 60.3 kB With provenance Details for meddeid_core-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for meddeid-core 0.2.4
File Interpreter ABI Platform Actions
meddeid_core-0.2.4-py3-none-any.whl Python 3 none any Details for meddeid_core-0.2.4-py3-none-any.whl

Total release size: 118.5 kB

Release files / meddeid_core-0.2.4.tar.gz

Download URL meddeid_core-0.2.4.tar.gz
Size 60.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a9b98d36ce364f6738ea30598c61c94f900a5d7f089b3428c78676cfe8722f09
BLAKE2b-256 checksum
How to use checksums
710909ccc34bdabd888ca52f4e24b62775b2e32cdc43e10c22da9dd5e26832bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / meddeid_core-0.2.4-py3-none-any.whl

Download URL meddeid_core-0.2.4-py3-none-any.whl
Size 58.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa67b739e36c64b1504b43759ba82805d39ac1d77fa69ace2b8fcbf2be077f56
BLAKE2b-256 checksum
How to use checksums
47078ff70428518c7903c0f547c13e747451425828773810ed307439064ff05c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for meddeid-core 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for meddeid_core-0.2.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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