implement ngrams as global feature function