<commit_before># -*- coding: utf-8 -*-

import json


def field_property(validator):
    """Decorator to define properties that map to the internal `_field`
    dict.

    The argument is a "validator" function that should return no value but
    raise an exception if the provided value is not valid Vega. If the
    validator throws no exception, then the value is assigned to the
    `_field` dict using the validator function name as the key.

    The validator function should take only one argument, so that no `self`
    argument is included - the validator should not modify the class.

    The docstring for the property is taken from the validator's docstring.
    """
    name = validator.__name__

    def setter(self, value):
        validator(value)
        self._field[name] = value

    def getter(self):
        return self._field.get(name, None)

    def deleter(self):
        if name in self._field:
            del self._field[name]

    return property(getter, setter, deleter, validator.__doc__)


class Scale(object):
    def __init__(self, name):
        self._field = {}
        self.name = name

    @field_property
    def name(value):
        """Name of the scale."""
        if not isinstance(value, str):
            raise TypeError('name must be string')

    @field_property
    def reverse(value):
        """If `True`, flip the range of the scale."""
        if not isinstance(value, bool):
            raise TypeError('reverse must be bool')

    def to_json(self):
        return json.dumps(self._field)
<commit_msg>Removing Scale to start with a clean slate.<commit_after># -*- coding: utf-8 -*-

import json


def field_property(validator):
    """Decorator to define properties that map to the internal `_field`
    dict.

    The argument is a "validator" function that should return no value but
    raise an exception if the provided value is not valid Vega. If the
    validator throws no exception, then the value is assigned to the
    `_field` dict using the validator function name as the key.

    The validator function should take only one argument, so that no `self`
    argument is included - the validator should not modify the class.

    The docstring for the property is taken from the validator's docstring.
    """
    name = validator.__name__

    def setter(self, value):
        validator(value)
        self._field[name] = value

    def getter(self):
        return self._field.get(name, None)

    def deleter(self):
        if name in self._field:
            del self._field[name]

    return property(getter, setter, deleter, validator.__doc__)

{'fraction_non_alphanumeric': 0.07880642693190512, 'fraction_numerical': 0.0007651109410864575, 'mean_word_length': 2.751793400286944, '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': '2173692', 'n_tokens_mistral': 726, 'n_tokens_neox': 696, 'n_words': 301}