(self, text)
| 212 | return word |
| 213 | |
| 214 | def encode(self, text): |
| 215 | bpe_tokens = [] |
| 216 | text = self.clean_fn(text) |
| 217 | for token in re.findall(self.pat, text): |
| 218 | token = ''.join(self.byte_encoder[b] for b in token.encode('utf-8')) |
| 219 | bpe_tokens.extend(self.encoder[bpe_token] for bpe_token in self.bpe(token).split(' ')) |
| 220 | return bpe_tokens |
| 221 | |
| 222 | def decode(self, tokens): |
| 223 | text = ''.join([self.decoder[token] for token in tokens]) |
no test coverage detected