| 217 | } |
| 218 | |
| 219 | void Processor::SetQuery(string const & query, bool categorialRequest /* = false */) |
| 220 | { |
| 221 | LOG(LDEBUG, ("query:", query, "isCategorial:", categorialRequest)); |
| 222 | |
| 223 | m_query.m_query = query; |
| 224 | m_query.m_tokens.clear(); |
| 225 | m_query.m_prefix.clear(); |
| 226 | |
| 227 | // Following code splits input query by delimiters except hash tags |
| 228 | // first, and then splits result tokens by hashtags. The goal is to |
| 229 | // retrieve all tokens that start with a single hashtag and leave |
| 230 | // them as is. |
| 231 | |
| 232 | Delimiters delims; |
| 233 | auto normalizedQuery = NormalizeAndSimplifyString(query); |
| 234 | PreprocessBeforeTokenization(normalizedQuery); |
| 235 | SplitUniString(normalizedQuery, base::MakeBackInsertFunctor(m_query.m_tokens), delims); |
| 236 | |
| 237 | static_assert(kMaxNumTokens > 0, ""); |
| 238 | size_t const maxTokensCount = kMaxNumTokens - 1; |
| 239 | if (m_query.m_tokens.size() > maxTokensCount) |
| 240 | { |
| 241 | m_query.m_tokens.resize(maxTokensCount); |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | // Assign the last parsed token to prefix. |
| 246 | if (!m_query.m_tokens.empty() && !delims(normalizedQuery.back())) |
| 247 | { |
| 248 | m_query.m_prefix.swap(m_query.m_tokens.back()); |
| 249 | m_query.m_tokens.pop_back(); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | QuerySliceOnRawStrings const tokenSlice(m_query.m_tokens, m_query.m_prefix); |
| 254 | |
| 255 | // Get preferred types to show in results. |
| 256 | m_preferredTypes.clear(); |
| 257 | m_isCategorialRequest = categorialRequest; |
| 258 | |
| 259 | FillCategories(tokenSlice, GetCategoryLocales(), m_categories, m_preferredTypes); |
| 260 | |
| 261 | if (ftypes::IsNationalCuisineChecker::Instance()(m_preferredTypes)) |
| 262 | m_isCategorialRequest = true; |
| 263 | |
| 264 | if (!m_isCategorialRequest) |
| 265 | { |
| 266 | // Assign tokens and prefix to scorer. |
| 267 | m_keywordsScorer.SetKeywords(m_query); |
| 268 | |
| 269 | ForEachCategoryType(tokenSlice, [&](size_t, uint32_t t) { m_preferredTypes.push_back(t); }); |
| 270 | } |
| 271 | |
| 272 | base::SortUnique(m_preferredTypes); |
| 273 | } |
| 274 | |
| 275 | m2::PointD Processor::GetPivotPoint(bool viewportSearch) const |
| 276 | { |
nothing calls this directly
no test coverage detected