Code to pre/post-process text for statistical chunking