<commit_before><commit_msg>coerce things with a dict (e.g. optparse.options) to a dict, esp. for use as kwargs<commit_after>#!/usr/bin/env python

def as_dict(likeDict):
    if isinstance(likeDict, dict):
        return likeDict
    else:
        try:
            return likeDict.__dict__
        except:
            raise TypeError("Can't coerce {} to act like a dict".format(likeDict))
{'fraction_non_alphanumeric': 0.10077519379844961, 'fraction_numerical': 0.0, 'mean_word_length': 2.766990291262136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5182708', 'n_tokens_mistral': 120, 'n_tokens_neox': 116, 'n_words': 36}