[WIP] Speed up text tokenizer

This is https://github.com/scrapinghub/webstruct/pull/15, but from the branch in webstruct repo and with some extra commits.