MCPcopy Create free account
hub / github.com/catboost/catboost / CheckMultitoken

Function CheckMultitoken

library/cpp/tokenizer/multitokenutil.cpp:253–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253bool CheckMultitoken(const TWideToken& tok) {
254 const TTokenStructure& subtokens = tok.SubTokens;
255 for (size_t i = 0; i < subtokens.size(); ++i) {
256 const TCharSpan& s = subtokens[i];
257 if (!s.Len)
258 Y_ASSERT(false);
259 if (i > 0) {
260 const TCharSpan& prev = subtokens[i - 1];
261 if (prev.EndPos() + prev.SuffixLen > s.Pos - s.PrefixLen)
262 Y_ASSERT(false);
263 else if (prev.EndPos() + prev.SuffixLen == s.Pos - s.PrefixLen && prev.TokenDelim != TOKDELIM_NULL)
264 Y_ASSERT(false);
265 }
266 if (i + 1 < subtokens.size()) {
267 const TCharSpan& next = subtokens[i + 1];
268 if (s.EndPos() + s.SuffixLen > next.Pos - next.PrefixLen)
269 Y_ASSERT(false);
270 else if (s.EndPos() + s.SuffixLen == next.Pos - next.PrefixLen && s.TokenDelim != TOKDELIM_NULL)
271 Y_ASSERT(false);
272 } else {
273 if (s.EndPos() + s.SuffixLen != tok.Leng || s.TokenDelim != TOKDELIM_NULL)
274 Y_ASSERT(false);
275 }
276 }
277 return (subtokens.empty() || tok.Leng == (subtokens.back().EndPos() + subtokens.back().SuffixLen));
278}

Callers 2

MakeMultitokenEntryMethod · 0.85
SetMultitokenMethod · 0.85

Calls 4

EndPosMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected