Comprehensive Python package for stylometric analysis
Project description
pystylometry
Stylometric analysis and authorship attribution for Python. 50+ metrics across 11 modules, from vocabulary diversity to AI-generation detection.
Install
pip install pystylometry # Core (lexical metrics)
pip install pystylometry[all] # Everything
Modules
| Module | Metrics | Description |
|---|---|---|
| lexical | TTR, MTLD, Yule's K/I, Hapax, MATTR, VocD-D, HD-D, MSTTR, function words, word frequency | Vocabulary diversity and richness |
| readability | Flesch, Flesch-Kincaid, SMOG, Gunning Fog, Coleman-Liau, ARI, Dale-Chall, Fry, FORCAST, Linsear Write, Powers-Sumner-Kearl | Grade-level and difficulty scoring |
| syntactic | POS ratios, sentence types, parse tree depth, clausal density, passive voice, T-units, dependency distance | Sentence and parse structure (requires spaCy) |
| authorship | Burrows' Delta, Cosine Delta, Zeta, Kilgarriff chi-squared, MinMax, John's Delta, NCD | Author attribution and text comparison |
| stylistic | Contractions, hedges, intensifiers, modals, punctuation, vocabulary overlap (Jaccard/Dice/Cosine/KL), cohesion, genre/register | Style markers and text similarity |
| character | Letter frequencies, digit/uppercase ratios, special characters, whitespace | Character-level fingerprinting |
| ngrams | Word/character/POS n-grams, Shannon entropy, skipgrams | N-gram profiles and entropy |
| dialect | British/American classification, spelling/grammar/vocabulary markers, markedness | Regional dialect detection |
| consistency | Sliding-window chi-squared drift, pattern classification | Intra-document style analysis |
| prosody | Syllable stress, rhythm regularity | Prose rhythm (requires spaCy) |
| viz | Timeline, scatter, report (PNG + interactive HTML) | Drift detection visualization |
Development
git clone https://github.com/craigtrim/pystylometry && cd pystylometry
pip install -e ".[dev,all]"
make test # 1022 tests
make lint # ruff + mypy
make all # lint + test + build
License
MIT
Author
Craig Trim -- craigtrim@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pystylometry-1.4.0.tar.gz
(236.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pystylometry-1.4.0-py3-none-any.whl
(277.7 kB
view details)
File details
Details for the file pystylometry-1.4.0.tar.gz.
File metadata
- Download URL: pystylometry-1.4.0.tar.gz
- Upload date:
- Size: 236.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.9 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98b371e2a652e998043216455babcd6cf80ba42aa59297ac280202d9647a8fba
|
|
| MD5 |
67c08019a360d34e3ca4641778900d15
|
|
| BLAKE2b-256 |
173a5e3b166c102f00f61f62213abbafc02e48d308cddcf1ff0b491cdbb01a5a
|
File details
Details for the file pystylometry-1.4.0-py3-none-any.whl.
File metadata
- Download URL: pystylometry-1.4.0-py3-none-any.whl
- Upload date:
- Size: 277.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.9 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d84cabb717c16f32dcccb5bec1a3248027074db37da120e2a4474b1fd7a2b3b6
|
|
| MD5 |
c973512a803f546ff120278d0aaad0c4
|
|
| BLAKE2b-256 |
87fa97647d8357e11f4d5744e5d07a45078fa5befd0625d1b04356888a1677da
|