lexical-diversity
A simple program for calcuating lexical diversity
What it is and what it does
Lexical-diversity is a Python library for computing quantitative measures of vocabulary diversity in text. It provides implementations of multiple diversity metrics—including Type-Token Ratio (TTR), Root TTR, Log TTR, Mean Segmental TTR, Moving Average TTR, Hypergeometric Distribution D (HDD), and Measure of Lexical Textual Diversity (MTLD)—each suited to different text lengths and analytical goals. The package includes convenience functions for tokenization and lemmatization, allowing users to preprocess text before calculating diversity scores.
The library is designed for linguistic research, computational text analysis, and language assessment tasks where understanding vocabulary breadth and repetition patterns is important. It has no external runtime dependencies, making it lightweight to install. However, the project is dormant—last released in 2020 and last committed in 2023—so users should not expect active maintenance or updates for newer Python versions or linguistic standards.
Use it for:
- Assess vocabulary richness in student writing samples or language learner essays to measure linguistic development
- Compare lexical diversity across different text corpora or authors to identify stylistic or quality differences
- Analyze vocabulary variation in clinical speech samples to detect language disorders or cognitive decline
- Evaluate machine-generated text quality by measuring how repetitive or diverse its vocabulary is
- Conduct computational linguistics research requiring multiple diversity metrics on the same text
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Calculates lexical diversity metrics (TTR, MTLD, HDD, and others) on tokenized text to measure vocabulary richness and variation.
Yes, if you need lexical diversity metrics for research or analysis and accept dormant maintenance. The package is lightweight, dependency-free, and offers multiple well-established metrics. However, verify compatibility with your Python version before relying on it in production, and consider whether a more actively maintained alternative better fits your timeline.
Install
lexical-diversity on PyPI
pip
pip install lexical-diversityuv
uv add lexical-diversitypoetry
poetry add lexical-diversityInstalling lexical-diversity
Before you install
Installs with no runtime dependencies. Maintenance is dormant—last release was 2020-03-04 and last commit 2023-09-15—but the repository remains active and the package is stable enough for research use.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for academic and production contexts.
Quickstart
pip install lexical-diversity
from lexical_diversity import lex_div as ld
text = "The state was named for the Colorado River..."
tok = ld.tokenize(text)
flt = ld.flemmatize(tok)
print(ld.ttr(flt))
print(ld.mtld(flt))
Verify before relying
- Whether the package works with modern Python versions (3.9+) despite no explicit version constraint in metadata
- Performance characteristics on very large texts or batch processing scenarios
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 2,354 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 98,665/month — #13,066 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: lexical_diversity-0.1.1-py3-none-any.whl
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
textacytextacy extends spaCy's NLP capabilities with…
permissive · top 15,000 on PyPI
syllapyCounts syllables in English words, returning an…
permissive · top 5,000 on PyPI
textstatTextstat calculates readability and complexity…
permissive · top 5,000 on PyPI
tokenizerTokenizes Icelandic text into words,…
permissive · top 15,000 on PyPI
lemminflectLemmatizes and inflects English words using…
permissive · top 15,000 on PyPI
nltkNLTK is a Python library for natural language…
permissive · top 1,000 on PyPI
polyglotPolyglot is a multilingual natural language…
copyleft · top 15,000 on PyPI
segmentsSegments provides Unicode-aware tokenization…
permissive · top 5,000 on PyPI
wonderwordsGenerates random English words and sentences…
permissive · top 15,000 on PyPI
accessCalculates spatial accessibility metrics to…
permissive · top 15,000 on PyPI