Encoding word n-grams to one-hot encoding is simple, however, it usually need large memory space. In this tutorial, we will introduce a new way to encode n-grams to one-hot encoding, it can create a one-hot matrix dynamically and need a little of memory space.