add ngrams core function.