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

Method MakeMultitokenEntry

library/cpp/tokenizer/nlpparser.cpp:82–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82template<> void TVersionedNlpParser<2>::MakeMultitokenEntry(TParserToken& token, const wchar16* entry) {
83 size_t entryLen = token.GetLength();
84
85 TTokenStructure subtokens;
86 token.CorrectPositions();
87 Y_ASSERT(token.GetLength() == entryLen); // check after the correction
88 token.SwapSubtokens(subtokens);
89
90 const wchar16* tokenText = entry;
91 size_t tokenLen = entryLen;
92 NLP_TYPE type = token.GetNlpType();
93 wchar16 buffer[TOKEN_MAX_BUF];
94 if (token.HasHyphen()) {
95 type = PrepareMultitoken(subtokens, buffer, TOKEN_MAX_BUF, entry, tokenLen);
96 Y_ASSERT(tokenLen <= TOKEN_MAX_LEN); // multitoken isn't longer than TOKEN_MAX_LEN
97 tokenText = buffer;
98 } else {
99 // NLP_WORD, NLP_INTEGER, NLP_FLOAT, NLP_MARK are needed to be cut off
100 Y_ASSERT(type == NLP_WORD || type == NLP_INTEGER || type == NLP_FLOAT || type == NLP_MARK);
101 if (tokenLen > TOKEN_MAX_LEN) {
102 // entry here always points to the original text
103 CutTooLongMultitoken(subtokens, entry, tokenLen, entryLen, type);
104 tokenText = entry; // in case if leading accents were removed...
105 }
106 }
107
108 TWideToken multitoken; // don't call to constructor TWideToken(entry, leng)!
109 multitoken.Token = tokenText;
110 multitoken.Leng = tokenLen;
111 multitoken.SubTokens.swap(subtokens);
112 Y_ASSERT(CheckMultitoken(multitoken));
113
114 const size_t totalLen = entryLen + GetExtraLen(entry, entryLen);
115
116 Y_ASSERT(multitoken.SubTokens.size());
117 if (BackwardCompatible) {
118 PassBackwardCompatibleToken(multitoken, type, totalLen);
119 } else {
120 SentBreakFilter.OnToken(multitoken, type);
121 TokenHandler.OnToken(multitoken, totalLen, type);
122 }
123}
124
125void TVersionedNlpParser<3>::MakeMultitokenEntry(TParserToken& token, const wchar16* entry) {
126 size_t entryLen = token.GetLength();

Callers

nothing calls this directly

Calls 12

PrepareMultitokenFunction · 0.85
CheckMultitokenFunction · 0.85
MakeEntryFunction · 0.85
CorrectPositionsMethod · 0.80
SwapSubtokensMethod · 0.80
HasHyphenMethod · 0.80
GetLengthMethod · 0.45
GetNlpTypeMethod · 0.45
swapMethod · 0.45
sizeMethod · 0.45
OnTokenMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected