#!/usr/bin/env bash # proofread -- full proofreading pipeline set -euo pipefail file="${1:?Usage: proofread }" 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"