Added n-gram functionality