Skip to main content

merkmal Python Wrapper

This package exposes the merkmal C99 library to Python through a CPython Limited API extension module, merkmal._native.

The current wrapper covers the high-level native slice:

  • list_systems
  • get_features
  • is_segment
  • distance
  • feature_distance
  • normalize
  • segment_ipa
  • merge_tone_digits
  • segment_ipa_merged
  • Registry
  • operation_fingerprint
  • fixed_space_distance
  • load_geometry and geometry_distance (experimental JSON geometry path)

The package is intentionally native-only. The pre-C Python implementation has been removed from the active package; old tutorials, notebooks, and research scripts live under docs/legacy_python/ as historical reference material.

import merkmal

print(merkmal.list_systems())
print(merkmal.get_features("pʰ"))
print(merkmal.distance("p", "b", node_weights="ignore-tone"))
print(merkmal.merge_tone_digits(["a", "5", "5"]))
print(merkmal.segment_ipa_merged("tʰoŋ⁵⁵"))

The descriptive system accepts synthesized source-token segments used by lexical datasets, including vowel clusters, selected author-defined consonant clusters, precomposed Latin source letters, and tone-bearing nuclei:

print(merkmal.is_segment("aːi³³", system="descriptive"))
print(merkmal.is_segment("ɛï³³", system="descriptive"))
print(merkmal.is_segment("kɣ", system="descriptive"))
print(merkmal.is_segment("ṵː", system="descriptive"))
print(merkmal.is_segment("ñ", system="descriptive"))
print(merkmal.get_features("ai", system="descriptive"))
print(merkmal.distance("ai", "a", system="descriptive"))

Vowel clusters use short synthetic features such as diphthong, n1-open, n2-close, and move-height-open-close. Consonant clusters use consonant-cluster, positional component features such as n1-nasal and n2-stop, plus geminate or pre-nasalized when the component sequence supports those readings. Markup/control tokens such as <?>, <<->>, and → are still rejected. Bare mb and nd resolve, as two-component clusters carrying pre-nasalized alongside their n1-/n2- component features. Use the explicit notation ᵐb or ⁿd when a single prenasalized segment is meant rather than a sequence: that form resolves to one segment with pre-nasalized and no component features.

Use is_segment() as the non-throwing predicate for source tokens. Unknown tokens return False from is_segment() and raise ValueError from get_features().

Runtime categorical models can be registered on an owned native registry:

registry = merkmal.Registry()
registry.add_model_text("""
@model toy
@type categorical
@geometry clements-hume
grapheme X consonant voiceless bilabial stop
""")
print(registry.get_features("X", system="toy"))

Registry owns its C registry handle, and each of its methods is the top-level function of the same name pointed at that registry. Top-level calls use a shared default registry holding the built-in systems; a model added to a Registry is visible only through it, and add_model_text refuses to touch the shared one.

feature_distance takes no system: it measures a distance in the compiled geometry, which every system shares.

Development

From the repository root:

python -m pip install -e ".[dev]"
python -m pytest python/tests -q
python -m build --sdist --wheel

The extension is built with Py_LIMITED_API=0x030C0000, producing a cp312-abi3 wheel.

Metadata

Release files for merkmal 0.9.0

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

Source distribution (sdist)

Source distribution for merkmal 0.9.0
File Size Uploaded Provenance Actions
merkmal-0.9.0.tar.gz 314.9 kB With provenance Details for merkmal-0.9.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for merkmal 0.9.0
File Actions
merkmal-0.9.0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for merkmal-0.9.0-cp312-abi3-musllinux_1_2_x86_64.whl
merkmal-0.9.0-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details for merkmal-0.9.0-cp312-abi3-musllinux_1_2_aarch64.whl
merkmal-0.9.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for merkmal-0.9.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
merkmal-0.9.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for merkmal-0.9.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Total release size: 1.7 MB

Release files / merkmal-0.9.0.tar.gz

Download URL merkmal-0.9.0.tar.gz
Size 314.9 kB
Tags Source
SHA-256 checksum
How to use checksums
607f042b7405520962bbf96e112eda173faa8c2e00b8fb40fafe87f2d95d7687
BLAKE2b-256 checksum
How to use checksums
f9470fa6f00ee55228c44a3c12cb0b779853a1fbf65715f4e4e32b3e7162f483
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 10, 2026.

Transparency log

Release files / merkmal-0.9.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL merkmal-0.9.0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 338.1 kB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
b4e71424fee43d6b4d3c20b02caa084950411c62e02a21016310f9e7a10c5e6c
BLAKE2b-256 checksum
How to use checksums
01ff7efde7e9bd7d401d57f226d94a97210634b9a17c66ee0304dd4176ed8da9
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 10, 2026.

Transparency log

Release files / merkmal-0.9.0-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL merkmal-0.9.0-cp312-abi3-musllinux_1_2_aarch64.whl
Size 333.1 kB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
3ca6617ff5996bc95411ab864e576a133f2b732040808d195667f714acc9831c
BLAKE2b-256 checksum
How to use checksums
a35d4b7a70996d3295dc9e87baf72958607b90d19f5965b60191c7c22c92d141
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 10, 2026.

Transparency log

Release files / merkmal-0.9.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL merkmal-0.9.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 338.8 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
7081e695265dc867d81b38680dff48da929a344e8f4688091ea6f622981fb6aa
BLAKE2b-256 checksum
How to use checksums
5799f33166e09b863e1be989d2e8df4243857bb9d44b340ddafcddf8fbd5139b
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 10, 2026.

Transparency log

Release files / merkmal-0.9.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL merkmal-0.9.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 336.9 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
6a6ea0b31feac74b6b9f92abd0e08e30b43f1eff0a5e7f9ea5f7dfff415fc1db
BLAKE2b-256 checksum
How to use checksums
bc7dc341dd6fbc5991330b536e8e330e4832a8dab6759a13607c6aacbc023dce
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 10, 2026.

Transparency log

Security for merkmal 0.9.0

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

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for merkmal-0.9.0.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 10, 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