| 108 | |
| 109 | template <typename TTokenType> |
| 110 | void TUnigramDictionaryBuilderImpl::AddImpl(TConstArrayRef<TTokenType> tokens, ui64 weight) { |
| 111 | if (DictionaryOptions.TokenLevelType == ETokenLevelType::Word) { |
| 112 | for (const auto& token : tokens) { |
| 113 | TokenToCount[token] += weight; |
| 114 | } |
| 115 | } else { |
| 116 | auto updateTokenToCountFunc = [&] (TStringBuf token) { |
| 117 | TokenToCount[token] += weight; |
| 118 | }; |
| 119 | ApplyFuncToLetterNGrams( |
| 120 | tokens, |
| 121 | DictionaryOptions.GramOrder, |
| 122 | DictionaryOptions.EndOfWordTokenPolicy == EEndOfWordTokenPolicy::Insert, |
| 123 | updateTokenToCountFunc |
| 124 | ); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | TIntrusivePtr<TDictionary> TUnigramDictionaryBuilderImpl::FinishBuilding() { |
| 129 | Y_ENSURE(!IsBuildingFinish, "FinishBuilding method should be called only once."); |
nothing calls this directly
no test coverage detected