I would compile the document into a PDF and then use pdftotext
to convert it to a text file. You should disable all hyphenation and remove the page header (\pagestyle{empty}
) to get only the raw text.
This ensures that you are using the LaTeX output not the input which might differ.
Of course, if you want to do statistics about the LaTeX files and not the document generated by it, then you need to convert the source instead. Stripping all macros is very difficult because (La)TeX is quite dynamic and macros can be redefined anyway (even by itself). A full correct stripping could only be implemented in (La)TeX itself because of this and then it is still very difficult. Some tools might simply remove all macros and brace arguments. This might be enough for your tasks.
pdftotext
to convert it to a text file. This ensures that you are using the LaTeX output not the input which might differ. Of course, if you want to do statistics about the LaTeX files and not the document generated by it, then you need to convert the source instead.