def shrink_dict(mnemonic_dict:dict, vocab_limit:int) -> dict:
    """Takes a dict which maps numberstr -> List[word-strings], and
    limits each value so that it has at most vocab_limit entries.  If the dict
    is sorted (like the one on disk is), this keeps the most common words.
    """
    out = {}
    for numbers, wordlist in mnemonic_dict.items():
        if wordlist:
            out[numbers] = wordlist[:vocab_limit]
    return out