From b075f5f771d2af5efff97296e1ad9b0f250b60a1 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Thu, 23 May 2019 19:21:30 +0300 Subject: [PATCH] [search] Fix search synonyms for China --- data/synonyms.txt | 4 ++-- generator/search_index_builder.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/data/synonyms.txt b/data/synonyms.txt index c660336dd7..7ebb27722d 100644 --- a/data/synonyms.txt +++ b/data/synonyms.txt @@ -69,6 +69,6 @@ Yukon: YT Россия: РФ Китайская Народная Република: Китай, КНР -Китай: Китайская Народная Република, КНР +Китай: КНР People's Republic of China: China, PRC -China: People's Republic of China, PRC +China: PRC diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp index c81b309453..3cff6fc452 100644 --- a/generator/search_index_builder.cpp +++ b/generator/search_index_builder.cpp @@ -77,8 +77,10 @@ public: for (size_t i = 1; i < tokens.size(); ++i) { strings::Trim(tokens[i]); - // synonym should not has any spaces - ASSERT(tokens[i].find_first_of(" \t") == string::npos, ()); + // For consistency, synonyms should not have any spaces. + // For example, the hypothetical "Russia" -> "Russian Federation" mapping + // would have the feature with name "Russia" match the request "federation". It would be wrong. + CHECK(tokens[i].find_first_of(" \t") == string::npos, ()); m_map.insert(make_pair(tokens[0], tokens[i])); } }