Count n-grams of length N and store them in a shelve