data_juicer.ops.mapper.python_lambda_mapper module

class data_juicer.ops.mapper.python_lambda_mapper.PythonLambdaMapper(lambda_str: str = '', batched: bool = False, **kwargs)[源代码]

基类:Mapper

Mapper for executing Python lambda function on data samples.

__init__(lambda_str: str = '', batched: bool = False, **kwargs)[源代码]

Initialization method.

参数:
  • lambda_str -- A string representation of the lambda function to be executed on data samples. If empty, the identity function is used.

  • batched -- A boolean indicating whether to process input data in batches.

  • kwargs -- Additional keyword arguments passed to the parent class.

process_single(sample)[源代码]

For sample level, sample --> sample

参数:

sample -- sample to process

返回:

processed sample

process_batched(samples)[源代码]