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)
| 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. |
| 64 | |
| 65 | EOS is not expected in ids. |
| 66 | |
| 67 | Args: |
| 68 | ids: list of integers to be converted. |
| 69 | strip_extraneous: bool, whether to strip off extraneous tokens |
| 70 | (EOS and PAD). |
| 71 | |
| 72 | Returns: |
| 73 | s: human-readable string. |
| 74 | """ |
| 75 | if strip_extraneous: |
| 76 | ids = strip_ids(ids, list(range(self._num_reserved_ids or 0))) |
| 77 | return " ".join(self.decode_list(ids)) |
| 78 | |
| 79 | def decode_list(self, ids): |
| 80 | """Transform a sequence of int ids into a their string versions. |
no test coverage detected