data_juicer.ops.mapper.replace_content_mapper module

class data_juicer.ops.mapper.replace_content_mapper.ReplaceContentMapper(pattern: str | List[str] | None = None, repl: str | List[str] = '', *args, **kwargs)[source]

Bases: Mapper

Mapper to replace all content in the text that matches a specific regular expression pattern with a designated replacement string.

__init__(pattern: str | List[str] | None = None, repl: str | List[str] = '', *args, **kwargs)[source]

Initialization method.

Parameters:
  • pattern – regular expression pattern(s) to search for within text

  • repl – replacement string(s), default is empty string

  • args – extra args

  • kwargs – extra args

process_batched(samples)[source]