Registry / ai-ml / lexical-diversity

lexical-diversity

JSON →
library0.1.1pypypi✓ verified 85d ago

A Python library for calculating lexical diversity metrics such as TTR, HDD, MTLD, and vocd-D. Version 0.1.1 is current, with an irregular release cadence.

pip install lexical-diversity
INSTALL
IMPORT
SIG · LEXICAL-DIVERSITY
L
lexical-diversity
ai-mlpythonv0.1.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lexical_diversity
import lexical_diversity as ld
import lexical_diversity
Common alias 'ld' is recommended for brevity.

Calculate Type-Token Ratio using Flemm's method.

import lexical_diversity as ld text = "the cat sat on the mat another cat" ttr = ld.flemm_ttr(text) print(ttr)
Debug
Known issues
deprecatedSome functions like 'mtld' may require text preprocessing (punctuation removal). Not automatically handled.
fix
Strip punctuation and lowercase text before passing to MTLD.
affects: <=0.1.1
gotchaInput must be a single string, not a list of tokens. Many users pass a list and get TypeError.
fix
Ensure input is a string: ' '.join(tokens) if needed.
affects: *
Errors
Common errors & fixes
TypeError: expected string or bytes-like object
Passing a list of tokens instead of a single string.
fix
Use ' '.join(tokens) to convert the list to a string.
ValueError: input must be a string
Non-string input (e.g., integer or None).
fix
Convert input to string using str() or ensure you pass a proper text string.
Upgrade
Version history
0.1.1latest on PyPI · released Mar 4, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
lexical-diversity — pip install lexical-diversity · libregistry