Skip to main content

🔤 phoneme-entropy

Phoneme-level entropy, informativity, and maximum-entropy tools for Python.

A standalone, reproducible toolkit for information-theoretic phonology — built on top of entropy-estimators.

PyPI version Python License: MIT CI Dataset on HF

▶️ Try it in your browser — no install required

Open the quickstart in Google Colab


✨ What you get

  • 📊 Entropy & divergence estimators — MLE, James–Stein, Chao–Shen, Chao–Wang–Jost, NBRS, and NSB, bundled and ready to call.
  • 🔡 Segmental informativity & lexical information gain — per-phoneme next-phoneme surprisal, plus the lexical information gain (mean entropy of the words still compatible) at each phoneme, over words encoded as phoneme strings.
  • 🎲 Symmetric-Dirichlet inference — recover a concentration parameter α from an entropy estimate, with predicted rank/probability curves.
  • 🧮 Maximum-entropy fitting — fit a distribution to target feature expectations via the convex dual.
  • 📦 Batteries included — ships a CELEX sample so every example runs out of the box; reproducible, tested, and pip-installable.

🚀 Install

pip install phoneme-entropy
Optional extras
pip install "phoneme-entropy[plot]"   # matplotlib + seaborn for plot_ranks
pip install "phoneme-entropy[data]"   # Hugging Face datasets loader

⚡ Quickstart

from collections import defaultdict
import numpy as np, pandas as pd
from phoneme_entropy import (
    Entropy, estimate_alpha_entropy,
    segment_informativity, phoneme_prefix_entropy,
    compute_maxent_from_matrix,
)
from phoneme_entropy.data import load_sample

sample = load_sample()                       # bundled CELEX sample (Word = space-separated phonemes)

# Per-phoneme next-phoneme surprisal and lexical information gain
surprisal          = segment_informativity(sample["Word"])
lexical_info_gain  = phoneme_prefix_entropy(sample["Word"])

# Symmetric-Dirichlet concentration implied by an entropy estimate
phon = defaultdict(int)
for w in sample["Word"]:
    for p in w.split(): phon[p] += 1
alpha, se = estimate_alpha_entropy(list(phon.values()), n_boot=0)

📓 Notebooks & examples

Notebook Open What it does
Colab quickstart Self-contained: pip installs from PyPI and runs the full pipeline on the bundled sample.
Tutorial The same walkthrough for local or Colab use.
quickstart.py — Script version of the walkthrough.

🗂️ Data

A small CELEX-derived sample ships with the package — just call load_sample().

The full sample is mirrored as a 🤗 gated dataset (permissions-only) — access is granted to holders of a valid CELEX/LDC license (LDC96L14):

from phoneme_entropy.data import load_hf_dataset
ds = load_hf_dataset(split="train")   # after your access request is approved

🧰 API at a glance

Import Purpose
Entropy, FreqShrink, JS_KullbackLeibler, JS_JensenShannon Entropy / divergence estimators (MLE, JSE, Chao-Shen, CWJ, NBRS, NSB).
estimate_alpha_entropy, dirichlet_entropy, plot_ranks Symmetric-Dirichlet inference and rank/probability curves.
segment_informativity, lexical_information_gain Next-phoneme surprisal and lexical information gain over phoneme strings (phoneme_prefix_entropy is a backwards-compatible alias).
compute_maxent_from_matrix Maximum-entropy fit to feature expectations.
phoneme_entropy.data.load_sample, load_hf_dataset Data loaders.

📖 Citation & license

Released under the MIT License. Bundles third-party code — see THIRD_PARTY_LICENSES. If you use this library, please cite it (see CITATION.cff) along with the upstream entropy-estimators project.

Built with ❤️ for reproducible information-theoretic phonology.

Metadata

Release files for phoneme-entropy 0.1.2

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

Source distribution (sdist)

Source distribution for phoneme-entropy 0.1.2
File Size Uploaded
phoneme_entropy-0.1.2.tar.gz 41.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for phoneme-entropy 0.1.2
File Interpreter ABI Platform
phoneme_entropy-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 76.4 kB

Release files / phoneme_entropy-0.1.2.tar.gz

Download URL phoneme_entropy-0.1.2.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8d866fe4d4892c2dd82eb5f41e5001ad9ca69853a1cd9f0b2bdc72f96c76878b
BLAKE2b-256 checksum
How to use checksums
532c96f40c1a695da8130082070890a128f714e28c70f2f30411842978917f68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 20, 2026.

Transparency log

Release files / phoneme_entropy-0.1.2-py3-none-any.whl

Download URL phoneme_entropy-0.1.2-py3-none-any.whl
Size 34.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccbad89848b5b65cbe65bbdc49cf9d95a1b44fa86fcb4b2bbbf53e331bc3edee
BLAKE2b-256 checksum
How to use checksums
6c2909c225fd17d026a891dd35c1a012ee4b5db6241c1399f751657af78e911e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

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