MCPcopy Create free account
hub / github.com/SooLab/CGFormer / _clean_text

Method _clean_text

bert/tokenization_bert.py:473–484  ·  view source on GitHub ↗

Performs invalid character removal and whitespace cleanup on text.

(self, text)

Source from the content-addressed store, hash-verified

471 return False
472
473 def _clean_text(self, text):
474 """Performs invalid character removal and whitespace cleanup on text."""
475 output = []
476 for char in text:
477 cp = ord(char)
478 if cp == 0 or cp == 0xFFFD or _is_control(char):
479 continue
480 if _is_whitespace(char):
481 output.append(" ")
482 else:
483 output.append(char)
484 return "".join(output)
485
486
487class WordpieceTokenizer(object):

Callers

nothing calls this directly

Calls 2

_is_controlFunction · 0.85
_is_whitespaceFunction · 0.85

Tested by

no test coverage detected