Tools for text tokenization and encoding