(self, text)
| 98 | return word |
| 99 | |
| 100 | def encode(self, text): |
| 101 | bpe_tokens = [] |
| 102 | for token in re.findall(self.pat, text): |
| 103 | token = ''.join(self.byte_encoder[b] for b in token.encode('utf-8')) |
| 104 | bpe_tokens.extend(self.encoder[bpe_token] for bpe_token in self.bpe(token).split(' ')) |
| 105 | return bpe_tokens |
| 106 | |
| 107 | def decode(self, tokens): |
| 108 | text = ''.join([self.decoder[token] for token in tokens]) |
no test coverage detected