MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / decode

Method decode

NLP/EMNLP2019-MAL/src/preprocess/text_encoder.py:187–202  ·  view source on GitHub ↗

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-

(self, ids, strip_extraneous=False)

Source from the content-addressed store, hash-verified

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.
189
190 EOS is not expected in ids.
191
192 Args:
193 ids: list of integers to be converted.
194 strip_extraneous: bool, whether to strip off extraneous tokens
195 (EOS and PAD).
196
197 Returns:
198 s: human-readable string.
199 """
200 if strip_extraneous:
201 ids = strip_ids(ids, list(range(self._num_reserved_ids or 0)))
202 return " ".join(self.decode_list(ids))
203
204 def decode_list(self, ids):
205 """Transform a sequence of int ids into a their string versions.

Callers 6

data_readerFunction · 0.45
parse_argsFunction · 0.45
parse_argsFunction · 0.45
tokenizer.pyFile · 0.45
subword_decode.pyFile · 0.45
to_unicodeFunction · 0.45

Calls 2

decode_listMethod · 0.95
strip_idsFunction · 0.85

Tested by

no test coverage detected