def normalize(string, chars_to_remove=None, replacement='<STR_LIT>'):
ret = string.translate(str.maketrans({<EOL>'<STR_LIT>': '<STR_LIT:a>',<EOL>'<STR_LIT>': '<STR_LIT:a>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT:e>',<EOL>'<STR_LIT>': '<STR_LIT:i>',<EOL>'<STR_LIT>': '<STR_LIT:o>',<EOL>'<STR_LIT>': '<STR_LIT:o>',<EOL>'<STR_LIT>': '<STR_LIT:u>',<EOL>'<STR_LIT>': '<STR_LIT:u>',<EOL>'<STR_LIT>': '<STR_LIT:n>',<EOL>}))<EOL>if isinstance(chars_to_remove, dict):<EOL><INDENT>for chars, replace in chars_to_remove.items():<EOL><INDENT>reg = '<STR_LIT:[>' + re.escape(chars) + '<STR_LIT:]>'<EOL>ret = re.sub(reg, replace, ret)<EOL><DEDENT><DEDENT>elif isinstance(chars_to_remove, str):<EOL><INDENT>reg = '<STR_LIT:[>' + re.escape(chars_to_remove) + '<STR_LIT:]>'<EOL>ret = re.sub(reg, replacement, ret)<EOL><DEDENT>return ret<EOL>
Remove accented characters and such.

The argument chars_to_remove is a dictionary that maps a string of chars to
a single character. Every occurrence of every character in the first string
will be replaced by that second character passed as value. If only one
mapping is desired, chars_to_remove may be a single string, but a third
parameter, replacement, must be provided to complete the translation.