<commit_before>import collections

from datetime import date, datetime
from dateutil import parser
from six import itervalues
from six.moves import map

from .utils import DslBase, _make_dsl_class, ObjectBase, AttrDict, AttrList
from .exceptions import ValidationException

__all__ = [
    'construct_field', 'Field', 'Object', 'Nested', 'Date', 'Float', 'Double',
    'Byte', 'Short', 'Integer', 'Long', 'Boolean', 'Ip', 'Attachment',
    'GeoPoint', 'GeoShape', 'InnerObjectWrapper', 'Keyword', 'Text'
]

def construct_field(name_or_field, **params):
    # {"type": "text", "analyzer": "snowball"}
    if isinstance(name_or_field, collections.Mapping):
        if params:
            raise ValueError('construct_field() cannot accept parameters when passing in a dict.')
        params = name_or_field.copy()<commit_msg>[FIX]add String field to __init__ (#501)<commit_after>import collections

from datetime import date, datetime
from dateutil import parser
from six import itervalues
from six.moves import map

from .utils import DslBase, _make_dsl_class, ObjectBase, AttrDict, AttrList
from .exceptions import ValidationException

__all__ = [
    'construct_field', 'Field', 'Object', 'Nested', 'Date', 'String', 'Float', 'Double',
    'Byte', 'Short', 'Integer', 'Long', 'Boolean', 'Ip', 'Attachment',
    'GeoPoint', 'GeoShape', 'InnerObjectWrapper', 'Keyword', 'Text'
]

def construct_field(name_or_field, **params):
    # {"type": "text", "analyzer": "snowball"}
    if isinstance(name_or_field, collections.Mapping):
        if params:
            raise ValueError('construct_field() cannot accept parameters when passing in a dict.')
        params = name_or_field.copy()
{'fraction_non_alphanumeric': 0.132064247471743, 'fraction_numerical': 0.001784651992861392, 'mean_word_length': 4.98576512455516, 'pattern_counts': {'":': 4, '<': 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': '5869685', 'n_tokens_mistral': 505, 'n_tokens_neox': 503, 'n_words': 157}