ngrams function

Build N-grams and keep most frequent