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)
| 44 | return self._num_reserved_ids |
| 45 | |
| 46 | def encode(self, s): |
| 47 | """Transform a human-readable string into a sequence of int ids. |
| 48 | |
| 49 | The ids should be in the range [num_reserved_ids, vocab_size). Ids [0, |
| 50 | num_reserved_ids) are reserved. |
| 51 | |
| 52 | EOS is not appended. |
| 53 | |
| 54 | Args: |
| 55 | s: human-readable string to be converted. |
| 56 | |
| 57 | Returns: |
| 58 | ids: list of integers |
| 59 | """ |
| 60 | return [int(w) + self._num_reserved_ids for w in s.split()] |
| 61 | |
| 62 | def decode(self, ids, strip_extraneous=False): |
| 63 | """Transform a sequence of int ids into a human-readable string. |
no outgoing calls
no test coverage detected