Ngram encode scheme and df updates