Refactored generation of substrings within an n-gram to make use of the existing BaseText n-gram generation code.