Implemented the n-gram parser/generator.