MCPcopy Create free account
hub / github.com/SooLab/CGFormer / encode

Method encode

utils/simple_tokenizer.py:121–127  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

119 return word
120
121 def encode(self, text):
122 bpe_tokens = []
123 text = whitespace_clean(basic_clean(text)).lower()
124 for token in re.findall(self.pat, text):
125 token = ''.join(self.byte_encoder[b] for b in token.encode('utf-8'))
126 bpe_tokens.extend(self.encoder[bpe_token] for bpe_token in self.bpe(token).split(' '))
127 return bpe_tokens
128
129 def decode(self, tokens):
130 text = ''.join([self.decoder[token] for token in tokens])

Callers 3

folder2lmdbFunction · 0.45
tokenizeFunction · 0.45
tokenizeFunction · 0.45

Calls 3

bpeMethod · 0.95
whitespace_cleanFunction · 0.85
basic_cleanFunction · 0.85

Tested by

no test coverage detected