diff options
author | tatiana-yan <tatiana.kondakova@gmail.com> | 2020-06-30 10:30:20 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2020-07-02 14:57:02 +0300 |
commit | f4b0b9e8cff7d47b3c388e420bf87722a5c8978d (patch) | |
tree | a461e6a45c765a70d3f8b6a429b8003b40bd8662 /search | |
parent | 54bc99e61569f441819edfab1703fd69710a26b7 (diff) |
[search] Use languages similar to device and query languages.
Diffstat (limited to 'search')
-rw-r--r-- | search/processor.cpp | 5 | ||||
-rw-r--r-- | search/search_integration_tests/processor_test.cpp | 41 |
2 files changed, 44 insertions, 2 deletions
diff --git a/search/processor.cpp b/search/processor.cpp index 8eb673a880..1c76f2c943 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -29,6 +29,7 @@ #include "indexer/feature_covering.hpp" #include "indexer/feature_data.hpp" #include "indexer/feature_impl.hpp" +#include "indexer/feature_utils.hpp" #include "indexer/features_vector.hpp" #include "indexer/ftypes_matcher.hpp" #include "indexer/postcodes_matcher.hpp" @@ -202,7 +203,7 @@ void Processor::SetPreferredLocale(string const & locale) LOG(LINFO, ("New preferred locale:", locale)); int8_t const code = StringUtf8Multilang::GetLangIndex(languages::Normalize(locale)); - m_keywordsScorer.SetLanguages(LanguageTier::LANGUAGE_TIER_CURRENT, {code}); + m_keywordsScorer.SetLanguages(LanguageTier::LANGUAGE_TIER_CURRENT, feature::GetSimilar(code)); m_currentLocaleCode = CategoriesHolder::MapLocaleToInteger(locale); @@ -219,7 +220,7 @@ void Processor::SetInputLocale(string const & locale) int8_t const code = StringUtf8Multilang::GetLangIndex(languages::Normalize(locale)); LOG(LDEBUG, ("New input locale:", locale, "locale code:", code)); - m_keywordsScorer.SetLanguages(LanguageTier::LANGUAGE_TIER_INPUT, {code}); + m_keywordsScorer.SetLanguages(LanguageTier::LANGUAGE_TIER_INPUT, feature::GetSimilar(code)); m_inputLocaleCode = CategoriesHolder::MapLocaleToInteger(locale); } diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 2b4dddd9ec..61e8c9bf70 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -2937,5 +2937,46 @@ UNIT_CLASS_TEST(ProcessorTest, StreetWithNumber) TEST(ResultsMatch("11-я Магистральная 11 ", rules), ()); } } + +UNIT_CLASS_TEST(ProcessorTest, SimilarLanguage) +{ + string const countryName = "Wonderland"; + + auto testLanguage = [&](string language, string searchString, bool expectedRes) { + auto request = MakeRequest(searchString, language); + auto const & results = request->Results(); + TEST_EQUAL(results.size(), expectedRes ? 1 : 0, (results, language, searchString, expectedRes)); + }; + + TestMultilingualPOI poi(m2::PointD(0.0, 0.0), "default", + {{"en", "Jiyugaoka Station"}, + {"int_name", "international"}, + {"ja", "自由が丘"}, + {"ja_kana", "じゆうがおか"}, + {"ko", "지유가오카"}}); + + auto wonderlandId = + BuildCountry(countryName, [&](TestMwmBuilder & builder) { builder.Add(poi); }); + + SetViewport(m2::RectD(-1, -1, 1, 1)); + + // Languages to search: default, English, international, device language (English by default), + // languages similar to device language, input language, languages similar to input language. + + // Search must use default, English and international languages for any query locale. + testLanguage("it", "default", true); + testLanguage("it", "Jiyugaoka Station", true); + testLanguage("it", "international", true); + + testLanguage("ja", "自由が丘", true); + // ja_kana is similar to ja. Search must use both ja and ja_kana for ja locale. + testLanguage("ja", "じゆうがおか", true); + + // ko is not in language list if query locale is not ko. + testLanguage("ja", "지유가오카", false); + testLanguage("en", "지유가오카", false); + // ko is in language list if query locale is ko. + testLanguage("ko", "지유가오카", true); +} } // namespace } // namespace search |