diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-02-09 22:35:53 +0100 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-02-10 05:07:11 +0100 |
| commit | 563b48869cee85f345537cce09da0f991da46a9b (patch) | |
| tree | 7d74a12495c95db577421e5e8c245b1a2186d62e /scripts/stats.py | |
| parent | 2ba2d3ad1547f7b3e30b94cc070f64f2940a66ca (diff) | |
Word count analysis
Diffstat (limited to 'scripts/stats.py')
| -rw-r--r-- | scripts/stats.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/stats.py b/scripts/stats.py new file mode 100644 index 0000000..5cef3b6 --- /dev/null +++ b/scripts/stats.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +import json +import math +import sys + +with open(sys.argv[1]) as f: + posts = json.load(f) + +words = [p["wordCount"] for p in posts] +n = len(words) +total = sum(words) +mean = total / n +stddev = math.sqrt(sum(w * w for w in words) / n - mean * mean) + +print(f"Posts: {n}") +print(f"Total: {total} words") +print(f"Mean: {mean:.0f} words") +print(f"Std Dev: {stddev:.0f} words") +print() +print(f"{'Title':<60s} {'Words'}") +print(f"{'-----':<60s} {'-----'}") +for p in posts: + print(f"{p['title']:<60s} {p['wordCount']}") |
