Transform a sequence of int ids into a human-readable string. EOS is not expected in ids. Args: ids: list of integers to be converted. strip_extraneous: bool, whether to strip off extraneous tokens (EOS and PAD). Returns: s: human-readab
(self, ids, strip_extraneous=False)
| 76 | return [int(w) + self._num_reserved_ids for w in s.split()] |
| 77 | |
| 78 | def decode(self, ids, strip_extraneous=False): |
| 79 | """Transform a sequence of int ids into a human-readable string. |
| 80 | |
| 81 | EOS is not expected in ids. |
| 82 | |
| 83 | Args: |
| 84 | ids: list of integers to be converted. |
| 85 | strip_extraneous: bool, whether to strip off extraneous tokens |
| 86 | (EOS and PAD). |
| 87 | |
| 88 | Returns: |
| 89 | s: human-readable string. |
| 90 | """ |
| 91 | if strip_extraneous: |
| 92 | ids = strip_ids(ids, list(range(self._num_reserved_ids or 0))) |
| 93 | return " ".join(self.decode_list(ids)) |
| 94 | |
| 95 | def decode_list(self, ids): |
| 96 | """Transform a sequence of int ids into a their string versions. |
no test coverage detected