<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

import sqlalchemy.types as types
from sqlalchemy.ext.declarative import declarative_base
from ujson import dumps, loads
Base = declarative_base()


class JsonType(types.TypeDecorator):
    """Represents an immutable structure as a json-encoded string.

    Usage::

        JSONEncodedDict(255)

    """

    impl = types.Unicode

    def process_bind_param(self, value, dialect):
        if value:
            value = dumps(value)
        else:
            value = None

        return value

    def process_result_value(self, value, dialect):
        if value is not None:
            value = loads(value)
        return value


from holmes.models.domain import Domain  # NOQA
from holmes.models.page import Page  # NOQA
from holmes.models.review import Review  # NOQA
from holmes.models.fact import Fact  # NOQA
from holmes.models.violation import Violation  # NOQA
from holmes.models.worker import Worker  # NOQA
from holmes.models.keys import Key  # NOQA<commit_msg>Fixed JsonType<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import sqlalchemy.types as types
from sqlalchemy.ext.declarative import declarative_base
from ujson import dumps, loads
Base = declarative_base()


class JsonType(types.TypeDecorator):
    """Represents an immutable structure as a json-encoded string.

    Usage::

        JSONEncodedDict(255)

    """

    impl = types.Unicode

    def process_bind_param(self, value, dialect):
        if value:
            value = dumps(value)
        else:
            value = None

        return value

    def process_result_value(self, value, dialect):
        if value:
            value = loads(value)
        else:
            value = None
        return value


from holmes.models.domain import Domain  # NOQA
from holmes.models.page import Page  # NOQA
from holmes.models.review import Review  # NOQA
from holmes.models.fact import Fact  # NOQA
from holmes.models.violation import Violation  # NOQA
from holmes.models.worker import Worker  # NOQA
from holmes.models.keys import Key  # NOQA
{'fraction_non_alphanumeric': 0.08045977011494253, 'fraction_numerical': 0.0038314176245210726, 'mean_word_length': 2.7912885662431943, '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': '4118634', 'n_tokens_mistral': 653, 'n_tokens_neox': 606, 'n_words': 186}