Skip to main content

textmeasures

textmeasures is a Python package for quantitative text measurement. The current public preview focuses on frequency distributions, CoNLL-U based symbol extraction, rank-frequency curves, vocabulary richness, concentration/evenness metrics, and Zipf-family model fitting.

This is an early public release (0.1.0). The API is usable, but it may still evolve before a stable 1.0.0 release.

Installation

pip install textmeasures

For local development from source:

git clone https://github.com/Yihtsy/textmeasures.git
cd textmeasures
pip install -e .

Quick Start

from textmeasures import FreqDist, entropy, repeat_rate, gini, normalized_entropy

freqs = FreqDist([10, 5, 3, 1, 1])

print(freqs.to_list())
print(entropy(freqs))
print(repeat_rate(freqs))
print(gini(freqs))
print(normalized_entropy(freqs))

Distribution Objects

from textmeasures import FreqDist

fd = FreqDist([10, 5, 3, 1, 1])

relative = fd.to_rel_freqdist()
cumulative = fd.to_cum_freqdist()
cumulative_relative = fd.to_cum_rel_freqdist()
spectrum = fd.to_freq_spectrum()

print(relative.to_list())
print(cumulative.to_list())
print(cumulative_relative.to_list())
print(spectrum.to_list())

CoNLL-U Input

textmeasures can read CoNLL-U files and convert selected linguistic units into symbols or frequency distributions.

from textmeasures import conllu_to_freqdist, conllu_to_symbols

symbols = conllu_to_symbols(
    "sample.conllu",
    linguistic_unit="lemma",
    language="en",
    exclude_upos=("PUNCT", "SYM", "X"),
)

freqs = conllu_to_freqdist(
    "sample.conllu",
    linguistic_unit="word",
    language="en",
)

print(symbols[:10])
print(freqs.to_list())

Supported languages are en and zh. Supported linguistic units include word, lemma, letter, character, upos, deprel, and n_gram; availability depends on the selected language.

Zipf-Family Fitting

from textmeasures import (
    zipf_fitted_parameters,
    zipf_mandelbrot_fitted_parameters,
    zipf_alekseev_fitted_parameters,
)

freqs = [100, 53, 31, 19, 12, 8, 5, 3, 2, 1]

print(zipf_fitted_parameters(freqs))
print(zipf_mandelbrot_fitted_parameters(freqs))
print(zipf_alekseev_fitted_parameters(freqs))

Fitting methods support "log_ols", "linear_ols", and "chi_square".

API Overview

Category Main APIs
Distribution objects FreqDist, RelFreqDist, CumFreqDist, CumRelFreqDist, FreqSpectrum
CoNLL-U utilities conllu_to_symbols, conllu_to_freqdist, conllu_token_dict, conllu_token_is_valid
Entropy and repetition entropy, repeat_rate, inverse_repeat_rate, normalized_entropy, simpson, normalized_simpson
Curves pareto_curve, lorenz_curve, yih_curve
Points and richness h_point, k_point, n_point, m_point, r1, r2, r4, indicator_b
Concentration and evenness gini, camargo_evenness, sheldon_equitability, inverse_simpson_evenness, robin_hood
QUITA and related indicators curve_length, lambda_indicator, b1, b2, b3, b4, b5, b6, b8, b10
Thematic concentration thematic_concentration, secondary_thematic_concentration, proportional_thematic_concentration
Moments and Ord criteria origin_moment, central_moment, moments, ords_i, ords_s, ords_criterion
Zipf-family fitting zipf_fitted_parameters, zipf_mandelbrot_fitted_parameters, zipf_alekseev_fitted_parameters, rtmza_fitted_parameters

Accepted Inputs

Most functions accept descending integer frequency sequences or FreqDist-like objects. Integer sequences are treated as raw counts and sorted in descending order when needed.

Floating-point sequences are treated as probability or relative-frequency distributions. They must be finite, non-negative, one-dimensional, and sum to approximately 1.

Development Notes

This public release intentionally includes the frequency-distribution functionality only. Additional modules for length and syntactic-complexity measures are being held back until their external dependencies and documentation are ready for public installation.

License

License information will be added here.

Metadata

Release files for textmeasures 0.1.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 textmeasures 0.1.0
File Size Uploaded
textmeasures-0.1.0.tar.gz 19.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textmeasures 0.1.0
File Interpreter ABI Platform
textmeasures-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.8 kB

Release files / textmeasures-0.1.0.tar.gz

Download URL textmeasures-0.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
792d5c582839a39a40b7c4579470bb40a2209c79748b63575c31e19c4a4808f2
BLAKE2b-256 checksum
How to use checksums
7f6123cac158405aa567ac3e92b2baa9285a2372f63365aaf07f63b4bc9070e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Aug 4, 2026.

Transparency log

Release files / textmeasures-0.1.0-py3-none-any.whl

Download URL textmeasures-0.1.0-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d92d494900d327224c238f37650decbdb91940d035f16b6ec4084ce51758a100
BLAKE2b-256 checksum
How to use checksums
e7976c66656932fd9bc3b13165814983b17a7b6023bb5c79463308c3a48de49a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Aug 4, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

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