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

Method AddSubtoken

library/cpp/tokenizer/nlpparserbase.h:56–74  ·  view source on GitHub ↗

allowed suffixes: "+", "++" and "#"

Source from the content-addressed store, hash-verified

54 }
55 // allowed suffixes: "+", "++" and "#"
56 void AddSubtoken(const TCharSpan& span, size_t prefixLen, wchar16 prefixChar, wchar16 suffixChar) {
57 Y_ASSERT(Subtokens.size() < MAX_SUBTOKENS);
58
59 if (Subtokens.empty()) {
60 NlpType = (span.Type == TOKEN_WORD ? NLP_WORD : NLP_INTEGER);
61 } else {
62 if (NlpType != NLP_MARK && span.Type != Subtokens.back().Type)
63 NlpType = NLP_MARK;
64 }
65
66 Subtokens.push_back(span);
67 Subtokens.back().PrefixLen = prefixLen;
68
69 const size_t n = Subtokens.size();
70 if (n > 1)
71 CorrectDelimiters(Subtokens[n - 2], suffixChar, Subtokens[n - 1], prefixChar);
72
73 Y_ASSERT(NlpType == NLP_WORD || NlpType == NLP_MARK || NlpType == NLP_INTEGER);
74 }
75 void AddIdeograph(size_t len) {
76 Y_ASSERT(Subtokens.empty());
77 Subtokens.push_back(0, len, TOKEN_WORD);

Callers 1

AddTokenMethod · 0.80

Calls 5

CorrectDelimitersFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected