Skip to content

craigtrim/pystylometry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

117 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pystylometry

PyPI version Downloads Downloads/Month Python 3.9+ License: MIT Tests

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