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

Method CorrectPositions

library/cpp/tokenizer/nlpparserbase.h:84–96  ·  view source on GitHub ↗

returns length of all subtokens including prefix of the first subtoken and suffix of the last subtoken

Source from the content-addressed store, hash-verified

82 }
83 // returns length of all subtokens including prefix of the first subtoken and suffix of the last subtoken
84 size_t CorrectPositions() {
85 Y_ASSERT(!Subtokens.empty());
86 // position of the first subtoken can be non-zero in case of non-first subtoken
87 // but TWideToken::Token must point to the first character of the first subtoken (prefix included if any)
88 const size_t pos = Subtokens[0].Pos - Subtokens[0].PrefixLen;
89 if (pos) {
90 const size_t n = Subtokens.size();
91 for (size_t i = 0; i < n; ++i)
92 Subtokens[i].Pos -= pos;
93 }
94 Y_ASSERT(Subtokens[0].Pos == Subtokens[0].PrefixLen); // PrefixLen can be equal to 0
95 return Subtokens.back().EndPos() + Subtokens.back().SuffixLen;
96 }
97 void UpdateSuffix() {
98 if (Subtokens.empty())
99 Y_ASSERT(!"can't update suffix: no subtokens");

Callers 1

MakeMultitokenEntryMethod · 0.80

Calls 4

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

Tested by

no test coverage detected