(self, text)
| 119 | return word |
| 120 | |
| 121 | def encode(self, text): |
| 122 | bpe_tokens = [] |
| 123 | text = whitespace_clean(basic_clean(text)).lower() |
| 124 | for token in re.findall(self.pat, text): |
| 125 | token = ''.join(self.byte_encoder[b] for b in token.encode('utf-8')) |
| 126 | bpe_tokens.extend(self.encoder[bpe_token] for bpe_token in self.bpe(token).split(' ')) |
| 127 | return bpe_tokens |
| 128 | |
| 129 | def decode(self, tokens): |
| 130 | text = ''.join([self.decoder[token] for token in tokens]) |
no test coverage detected