<commit_before>from django.utils.functional import Promise
from django.utils.encoding import force_unicode
from simplejson import JSONEncoder

class LazyEncoder(JSONEncoder):
    def default(self, obj):
        if isinstance(obj, Promise):
            return force_unicode(obj)
        return obj<commit_msg>fallback to django's included simplejson if the user doesn't have it installed<commit_after>from django.utils.functional import Promise
from django.utils.encoding import force_unicode
try:
    from simplejson import JSONEncoder
except ImportError:
    from django.utils.simplejson import JSONEncoder

class LazyEncoder(JSONEncoder):
    def default(self, obj):
        if isinstance(obj, Promise):
            return force_unicode(obj)
        return obj
{'fraction_non_alphanumeric': 0.06036745406824147, 'fraction_numerical': 0.0, 'mean_word_length': 4.120805369127517, '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': '4858081', 'n_tokens_mistral': 195, 'n_tokens_neox': 186, 'n_words': 65}