MCPcopy Create free account
hub / github.com/apache/singa / _clean_text

Method _clean_text

examples/onnx/bert/tokenization.py:282–293  ·  view source on GitHub ↗

Performs invalid character removal and whitespace cleanup on text.

(self, text)

Source from the content-addressed store, hash-verified

280 return False
281
282 def _clean_text(self, text):
283 """Performs invalid character removal and whitespace cleanup on text."""
284 output = []
285 for char in text:
286 cp = ord(char)
287 if cp == 0 or cp == 0xfffd or _is_control(char):
288 continue
289 if _is_whitespace(char):
290 output.append(" ")
291 else:
292 output.append(char)
293 return "".join(output)
294
295
296class WordpieceTokenizer(object):

Callers 1

tokenizeMethod · 0.95

Calls 3

_is_controlFunction · 0.85
_is_whitespaceFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected