[文档]@OPERATORS.register_module("remove_specific_chars_mapper")classRemoveSpecificCharsMapper(Mapper):"""Removes specific characters from text samples. This operator removes specified characters from the text. The characters to be removed can be provided as a string or a list of strings. If no characters are specified, the default set includes special and non-alphanumeric characters. The operator processes the text using a regular expression pattern that matches any of the specified characters and replaces them with an empty string. This is done in a batched manner for efficiency."""_batched_op=True
[文档]def__init__(self,chars_to_remove:Union[str,List[str]]="◆●■►▼▲▴∆▻▷❖♡□",*args,**kwargs):""" Initialization method. :param chars_to_remove: a list or a string including all characters that need to be removed from text. :param args: extra args :param kwargs: extra args """super().__init__(*args,**kwargs)ifchars_to_remove:self.pattern="["+"|".join(chars_to_remove)+"]"else:self.pattern=None