<commit_before>from datetime import datetime
import re


class BaseField(object):

    name = None

    class InvalidData(Exception):
        """
        Should be raised, when invalid data is passed to the fied for
        serialization or deserialization.
        """
        pass

    def __init__(self, value=None, query_field=None):
        self._evaluate(value)
        self._query_field = query_field

    def _is_string(self, value):
        is_string = ((type(value) is str) or (type(value) is unicode))
        return is_string

    def _evaluate(self, value):
        if (self._is_string(value)):
            self._value = self.serialize(value)
        else:
            self._value = value

    def __get__(self, instance, owner):
        if (instance is None):
            return self
        return self.serialize(instance._data.get(self.name))

    def __set__(self, instance, value):
        self._evaluate(value)

    def serialize(self, value):
        return value

    def deserialize(self):
        return self._value

    def __unicode__(self):
        return self.deserialize()

    def __str__(self):
        return self.__unicode__()


class StringField(BaseField):
    pass


class IntegerField(BaseField):
    def serialize(self, value):
        return int(value)

    def deserialize(self):
        return str(self._value)


class DateTimeField(BaseField):

    _pattern = r'^(\d\d\d\d)-(\d\d)-(\d\d)[\sT](\d\d):(\d\d):(\d\d)'

    def serialize(self, value):
        matches = re.search(self._pattern, value)
        if (matches):
            matches = matches.groups()
            year, month, day, hour, minute, seconds = (
                int(matches[0]), int(matches[1]), int(matches[2]),
                int(matches[3]), int(matches[4]), int(matches[5])
            )
        return datetime(year, month, day, hour, minute, seconds)

<commit_msg>Made `jason.fields.BaseField` raise `NotImplementedError` when accessing `serialize` and `deserialize`<commit_after>from datetime import datetime
import re


class BaseField(object):

    name = None

    class InvalidData(Exception):
        """
        Should be raised, when invalid data is passed to the fied for
        serialization or deserialization.
        """
        pass

    def __init__(self, value=None, query_field=None):
        self._evaluate(value)
        self._query_field = query_field

    def _is_string(self, value):
        is_string = ((type(value) is str) or (type(value) is unicode))
        return is_string

    def _evaluate(self, value):
        if (self._is_string(value)):
            self._value = self.serialize(value)
        else:
            self._value = value

    def __get__(self, instance, owner):
        if (instance is None):
            return self
        return self.serialize(instance._data.get(self.name))

    def __set__(self, instance, value):
        self._evaluate(value)

    def serialize(self, value):
        raise NotImplementedError()

    def deserialize(self):
        raise NotImplementedError()

    def __unicode__(self):
        return self.deserialize()

    def __str__(self):
        return self.__unicode__()


class StringField(BaseField):
    def serialize(self, value):
        return value

    def deserialize(self):
        return self._value


class IntegerField(BaseField):
    def serialize(self, value):
        return int(value)

    def deserialize(self):
        return str(self._value)


class DateTimeField(BaseField):

    _pattern = r'^(\d\d\d\d)-(\d\d)-(\d\d)[\sT](\d\d):(\d\d):(\d\d)'

    def serialize(self, value):
        matches = re.search(self._pattern, value)
        if (matches):
            matches = matches.groups()
            year, month, day, hour, minute, seconds = (
                int(matches[0]), int(matches[1]), int(matches[2]),
                int(matches[3]), int(matches[4]), int(matches[5])
            )
        return datetime(year, month, day, hour, minute, seconds)


{'fraction_non_alphanumeric': 0.11908358509566969, 'fraction_numerical': 0.0030211480362537764, 'mean_word_length': 2.4073756432246998, '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': '2829937', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1130, 'n_words': 294}