Skip to content

Instantly share code, notes, and snippets.

@malloc47
Created October 25, 2011 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malloc47/1311155 to your computer and use it in GitHub Desktop.
Save malloc47/1311155 to your computer and use it in GitHub Desktop.
Flesch–Kincaid Index For *nix Man Pages
# prepossess: remove newlines, add newlines after end of sentences, trim whitespace, and remove short lines
man /usr/share/man/man1/git.1.gz | tr '\n' ' ' | sed 's/\./\.\n/g' | sed -e 's/^[ \t]*//' | sed '/.\{3\}/!d'
> man /usr/share/man/man1/git.1.gz | style
readability grades:
Kincaid: 7.0
ARI: 4.4
Coleman-Liau: 4.0
...
> awk '{avg+=$2} END {print avg/NR}' ~/flesch-kincaid
9.08134
> awk '{sum+=$2; sumsq+=$2*$2} END {print sqrt(sumsq/NR - (sum/NR)**2)}' ~/flesch-kincaid
10.3857
man /usr/share/man/man1/git.1.gz | style | grep Kincaid | awk '{print $2}'
for i in `ls -d -1 /usr/share/man/man?/*` ; do echo -n "$i " ; man $i | tr '\n' ' ' | sed 's/\./\.\n/g' | sed -e 's/^[ \t]*//' | sed '/.\{3\}/!d' | grep Kincaid | awk '{print $2}' ; done > ~/flesch-kincaid
grep `awk '$2>m{m=$2}END{print m}' ~/flesch-kincaid` ~/flesch-kincaid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment