MCPcopy Create free account
hub / github.com/THUDM/GLM / cnndm_detokenize

Function cnndm_detokenize

tasks/seq2seq/dataset.py:34–51  ·  view source on GitHub ↗
(string, is_target=False)

Source from the content-addressed store, hash-verified

32
33
34def cnndm_detokenize(string, is_target=False):
35 _tok_dict = {"(": "-LRB-", ")": "-RRB-",
36 "[": "-LSB-", "]": "-RSB-",
37 "{": "-LCB-", "}": "-RCB-"}
38 if not is_target:
39 string = string.replace("<S_SEP>", "")
40 else:
41 string = string.replace("<S_SEP>", "[SEP]")
42 for key, value in _tok_dict.items():
43 string = string.replace(value, key)
44 string = string.replace("''", "\"")
45 string = string.replace("``", "\"")
46 string = string.replace("`", "'")
47 string = string.replace(" n't", "n't")
48 string = string.replace(" 's", "'s")
49 string = string.replace(" 'd", "'d")
50 string = string.replace(" 'll", "'ll")
51 return string
52
53
54def blanklm_detokenize(string, is_target=False):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected