n-gram generation