<commit_before>"""
    Defines `dit` configuration parameters.
"""

import warnings

from .exceptions import InvalidBase

__all__ = ['ditParams', 'reset_params']

def validate_boolean(b):
    """Convert b to a boolean or raise a ValueError."""
    try:
        b = b.lower()
    except AttributeError:
        pass
    if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True): return True
    elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False): return False
    else:
        raise(ValueError('Could not convert "%s" to boolean' % b))

def validate_float(s):
    """Convert s to float or raise a ValueError."""
    try: 
        return float(s)
    except ValueError:
        raise(ValueError('Could not convert "%s" to float' % s))

def validate_base(b):
    """Convert s to a valid base or raise InvalidBase."""

    # String bases.
    if b == 'e' or b == 'linear':
        return b

    # Numerical bases.
    if b <= 0 or b == 1:
        raise InvalidBase(b)
    else:
        return b

def validate_choice(s, choices):
    try:
        s = s.lower()
    except AttributeError:
        pass
    if s not in choices:
        raise(ValueError("%s is an invalid specification." % s))
    else:
        return s

def validate_text(s):
    choices = ['ascii', 'linechar']
    return validate_choice(s, choices)

class DITParams(dict):
    """
    A dictionary including validation, representing dit parameters.

    """
    # A dictionary relating params to validators.
    def __init__(self, *args, **kwargs):
        self.validate = dict([(key, converter) for key, (default, converter) \
                              in defaultParams.iteritems()])
        dict.__init__(self, *args, **kwargs)

    def __setitem__(self, key, val):
        if key in _deprecated_map.keys():
            alt = _deprecated_map[key]<commit_msg>Python 3 compatibility: iteritems -> items<commit_after>"""
    Defines `dit` configuration parameters.
"""

import warnings

from .exceptions import InvalidBase

__all__ = ['ditParams', 'reset_params']

def validate_boolean(b):
    """Convert b to a boolean or raise a ValueError."""
    try:
        b = b.lower()
    except AttributeError:
        pass
    if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True): return True
    elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False): return False
    else:
        raise(ValueError('Could not convert "%s" to boolean' % b))

def validate_float(s):
    """Convert s to float or raise a ValueError."""
    try:
        return float(s)
    except ValueError:
        raise(ValueError('Could not convert "%s" to float' % s))

def validate_base(b):
    """Convert s to a valid base or raise InvalidBase."""

    # String bases.
    if b == 'e' or b == 'linear':
        return b

    # Numerical bases.
    if b <= 0 or b == 1:
        raise InvalidBase(b)
    else:
        return b

def validate_choice(s, choices):
    try:
        s = s.lower()
    except AttributeError:
        pass
    if s not in choices:
        raise(ValueError("%s is an invalid specification." % s))
    else:
        return s

def validate_text(s):
    choices = ['ascii', 'linechar']
    return validate_choice(s, choices)

class DITParams(dict):
    """
    A dictionary including validation, representing dit parameters.

    """
    # A dictionary relating params to validators.
    def __init__(self, *args, **kwargs):
        self.validate = dict([(key, converter) for key, (default, converter) \
                              in defaultParams.items()])
        dict.__init__(self, *args, **kwargs)

    def __setitem__(self, key, val):
        if key in _deprecated_map.keys():
            alt = _deprecated_map[key]
{'fraction_non_alphanumeric': 0.13110749185667753, 'fraction_numerical': 0.003528773072747014, 'mean_word_length': 2.543269230769231, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6147919', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1095, 'n_words': 389}