MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / cut

Method cut

python/paddle_serving_app/reader/tokenization.py:178–193  ·  view source on GitHub ↗
(self, chars)

Source from the content-addressed store, hash-verified

176 self.sp_model.Load(sp_model_dir)
177
178 def cut(self, chars): # pylint: disable=doc-string-missing
179 words = []
180 idx = 0
181 while idx < len(chars):
182 matched = False
183 for i in range(self.window_size, 0, -1):
184 cand = chars[idx:idx + i]
185 if cand in self.dict:
186 words.append(cand)
187 matched = True
188 break
189 if not matched:
190 i = 1
191 words.append(chars[idx])
192 idx += i
193 return words
194
195 def tokenize(self, text, unk_token="[UNK]"): # pylint: disable=doc-string-missing
196 text = convert_to_unicode(text)

Callers 1

tokenizeMethod · 0.95

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected