Here is a link to the git for a program that counts spelling and grammar mistakes in writing samples (a directory of plain text files). The spelling and grammar checkers are similar to the open source ones used in programs like OpenOffice.
https://github.com/gsaqui/command-line-spellchecker
We are using the program in some ongoing research projects.