def _clean_text(self, text):
output = []<EOL>for char in text:<EOL><INDENT>cp = ord(char)<EOL>if cp in (<NUM_LIT:0>, <NUM_LIT>) or self._is_control(char):<EOL><INDENT>continue<EOL><DEDENT>if self._is_whitespace(char):<EOL><INDENT>output.append('<STR_LIT:U+0020>')<EOL><DEDENT>else:<EOL><INDENT>output.append(char)<EOL><DEDENT><DEDENT>return '<STR_LIT>'.join(output)<EOL>
Performs invalid character removal and whitespace cleanup on text.