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

Function GetLetterIndices

library/cpp/text_processing/dictionary/util.h:20–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19 template <typename TTokenType>
20 static void GetLetterIndices(const TTokenType& token, TVector<ui32>* letterStartIndices) {
21 letterStartIndices->clear();
22 const unsigned char* current = reinterpret_cast<const unsigned char*>(token.data());
23 const ui32 tokenSize = token.size();
24 const unsigned char* last = current + tokenSize;
25 ui32 i = 0;
26 while (i < tokenSize) {
27 letterStartIndices->push_back(i);
28 size_t length = 0;
29 auto recodeResult = GetUTF8CharLen(length, current, last);
30 if (recodeResult != RECODE_OK || length == 0) {
31 letterStartIndices->clear();
32 return;
33 }
34 i += length;
35 current += length;
36 }
37 letterStartIndices->push_back(tokenSize);
38 }
39
40 template <bool needToAddEndOfWordToken, typename TTokenType, typename TVisitor>
41 static void ApplyFuncToLetterNGramsImpl(

Callers 1

Calls 5

GetUTF8CharLenFunction · 0.85
clearMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected