def make_ngrams(self, tokens, min_gram=3, max_gram=6):
        terms = {}

        for position, token in enumerate(tokens):
            for window_length in range(min_gram, min(max_gram + 1, len(token) + 1)):
                # Assuming "front" grams.
                gram = token[:window_length]
                terms.setdefault(gram, [])

                if not position in terms[gram]:
                    terms[gram].append(position)

        return terms


    # ================
    # Segment Handling
    # ================
Hack around unittest's stupid constructor.
dataset/ETHPy150Open toastdriven/microsearch/microsearch.py/Microsearch.make_ngrams--crossover with--dataset/ETHPy150Open google/grr/grr/lib/test_lib.py/GRRBaseTest.__init__