Decode the whitespace-encoded strings produced by encode_whitespace. >>> text = 'a\\n b\\n c' >>> s, l = 10, 10 >>> text == decode_whitespaces(encode_whitespaces(text, s, l), s, l) True
(text: str, start_extra_id: int, max_len: int)
| 16 | |
| 17 | |
| 18 | def decode_whitespaces(text: str, start_extra_id: int, max_len: int): |
| 19 | """ Decode the whitespace-encoded strings produced by encode_whitespace. |
| 20 | |
| 21 | >>> text = 'a\\n b\\n c' |
| 22 | >>> s, l = 10, 10 |
| 23 | >>> text == decode_whitespaces(encode_whitespaces(text, s, l), s, l) |
| 24 | True |
| 25 | """ |
| 26 | for l in range(2, max_len + 1): |
| 27 | token_id = start_extra_id - 2 + l |
| 28 | token = f'<|extratoken_{token_id}|>' |
| 29 | text = text.replace(token, ' ' * l) |
| 30 | return text |
| 31 | |
| 32 | |
| 33 | class CodeGeeXTokenizer(object): |