Transform a human-readable string into a sequence of int ids. The ids should be in the range [num_reserved_ids, vocab_size). Ids [0, num_reserved_ids) are reserved. EOS is not appended. Args: s: human-readable string to be converted. Returns:
(self, s)
| 169 | return self._num_reserved_ids |
| 170 | |
| 171 | def encode(self, s): |
| 172 | """Transform a human-readable string into a sequence of int ids. |
| 173 | |
| 174 | The ids should be in the range [num_reserved_ids, vocab_size). Ids [0, |
| 175 | num_reserved_ids) are reserved. |
| 176 | |
| 177 | EOS is not appended. |
| 178 | |
| 179 | Args: |
| 180 | s: human-readable string to be converted. |
| 181 | |
| 182 | Returns: |
| 183 | ids: list of integers |
| 184 | """ |
| 185 | return [int(w) + self._num_reserved_ids for w in s.split()] |
| 186 | |
| 187 | def decode(self, ids, strip_extraneous=False): |
| 188 | """Transform a sequence of int ids into a human-readable string. |
no outgoing calls
no test coverage detected