~kris/dots

srice

ref: 9f828eb14bdd54d2c4fd8a3b2c90253021df3152 srice/.local/bin/proofread -rwxr-xr-x 1.2 KiB
9f828eb1 — Kris Yotam mksh: backslash-escape commands in history hook to bypass module aliases (wc=tokei, tr=transmission-remote, cat=bat) 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# proofread -- full proofreading pipeline
set -euo pipefail
file="${1:?Usage: proofread <file>}"

echo "========== SPELLING =========="
cat "$file" | aspell list --lang=en --mode=markdown 2>/dev/null | sort -u || true

echo ""
echo "========== PASSIVE VOICE =========="
egrep -n -i --color=always \
    "\b(am|are|were|being|is|been|was|be)\b[ ]*(\w+ed)\b" "$file" || true

echo ""
echo "========== WEASEL WORDS =========="
egrep -n -i --color=always \
    "\b(many|various|very|fairly|several|extremely|quite|remarkably|few|surprisingly|mostly|largely|clearly|relatively|completely|significantly|substantially)\b" "$file" || true

echo ""
echo "========== REPEATED WORDS =========="
perl -ne 'while (/\b(\w+)\s+\1\b/gi) { print "$ARGV:$.: $1 $1\n"; }' "$file" || true

echo ""
echo "========== LONG SENTENCES (>35 words) =========="
awk 'BEGIN{RS="[.!?]"; n=0}{gsub(/\n/," "); wc=split($0,w," "); n++; if(wc>35) printf "Sentence %d (%d words)\n", n, wc}' "$file" || true

echo ""
echo "========== STATS =========="
words=$(wc -w < "$file")
sentences=$(grep -o '[.!?]' "$file" | wc -l)
[ "$sentences" -eq 0 ] && sentences=1
avg=$(( words / sentences ))
echo "Words: $words | Sentences: $sentences | Avg words/sentence: $avg"