def compile_vocab(docs, limit=1e6, verbose=0, tokenizer=Tokenizer(stem=None, lower=None, strip=None)):
    tokenizer = make_tokenizer(tokenizer)
    d = Dictionary()
    try:
        limit = min(limit, docs.count())
        docs = docs.iterator()
    except (AttributeError, TypeError):
        pass
    for i, doc in enumerate(docs):
        try:
            doc = doc.values()
        except AttributeError:
            if not isinstance(doc, str):
                doc = ' '.join([str(v) for v in doc])
            else:
                doc = str(doc)
        if i >= limit:
            break
        d.add_documents([list(tokenizer(doc))])
        if verbose and not i % 100:
            log.info('{}: {}'.format(i, repr(d)[:120]))
    return d