<commit_before># Copyright (c) 2014, 2015, 2016, 2017 <NAME> under LGPL version 2.1. See LICENSE for more information.
#
# chain - Support for chaining multiple IRField's (so for example to compress a json value)
#


# vim:set ts=8 shiftwidth=8 softtabstop=8 noexpandtab :

from ..compat_str import to_unicode

from . import IRField, irNull

try:
	unicode
except NameError:
	unicode = str

class IRFieldChain(IRField):

	# TODO: We can probably index if all chained field types are indexable, but just disallow for now.
	CAN_INDEX = False

	def __init__(self, name, chainedFields, defaultValue=irNull):
		if not name:
			raise ValueError('IRFieldChain has empty name.')

		self.chainedFields = []

		for field in chainedFields:
			# If we got jsut a class, construct it.
			if type(field) == type:<commit_msg>Add docstring to IRFieldChain<commit_after># Copyright (c) 2014, 2015, 2016, 2017 <NAME> under LGPL version 2.1. See LICENSE for more information.
#
# chain - Support for chaining multiple IRField's (so for example to compress a json value)
#


# vim:set ts=8 shiftwidth=8 softtabstop=8 noexpandtab :

from ..compat_str import to_unicode

from . import IRField, irNull

try:
	unicode
except NameError:
	unicode = str

class IRFieldChain(IRField):
	'''
	   IRFieldChain -
	   
	   These chain together the operations from multiple fields.

	   toStorage is applied left-to-right,
	   fromInput and fromStorage is applied right-to-left.

	   The output of one field is the input of the next.
	'''

	# TODO: We can probably index if all chained field types are indexable, but just disallow for now.
	CAN_INDEX = False

	def __init__(self, name, chainedFields, defaultValue=irNull):
		'''
			__init__ - Create an IRFieldChain object.

			  These chain together the operations from multiple fields.

			  toStorage is applied left-to-right,
			  fromInput and fromStorage is applied right-to-left.

			  The output of one field is the input of the next.


			@see IRField.__init__
		'''
		if not name:
			raise ValueError('IRFieldChain has empty name.')

		self.chainedFields = []

		for field in chainedFields:
			# If we got jsut a class, construct it.
			if type(field) == type:
{'fraction_non_alphanumeric': 0.07734553775743708, 'fraction_numerical': 0.019221967963386728, 'mean_word_length': 3.6909871244635193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3598948', 'n_tokens_mistral': 750, 'n_tokens_neox': 651, 'n_words': 268}