diff --git a/indexer/search_string_utils.cpp b/indexer/search_string_utils.cpp index cc4771d7bc..cf8a021da3 100644 --- a/indexer/search_string_utils.cpp +++ b/indexer/search_string_utils.cpp @@ -1,6 +1,9 @@ #include "indexer/search_string_utils.hpp" #include "indexer/string_set.hpp" +#include "indexer/transliteration_loader.hpp" + +#include "coding/transliteration.hpp" #include "coding/transliteration.hpp" @@ -58,6 +61,14 @@ void RemoveNumeroSigns(UniString & s) i = j; } } + +void TransliterateHiraganaToKatakana(UniString & s) +{ + InitTransliterationInstanceWithDefaultDirs(); + string out; + if (Transliteration::Instance().Transliterate(strings::ToUtf8(s), "Hiragana-Katakana", out)) + s = MakeUniString(out); +} } // namespace size_t GetMaxErrorsForTokenLength(size_t length) @@ -134,6 +145,7 @@ UniString NormalizeAndSimplifyString(string const & s) MakeLowerCaseInplace(uniString); NormalizeInplace(uniString); + TransliterateHiraganaToKatakana(uniString); // Remove accents that can appear after NFKD normalization. uniString.erase_if([](UniChar const & c) { diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 046778c2a9..b66d7b8b3e 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -3078,5 +3078,25 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_IsAltOrOldName) checkIsAltOrOldName("Питер проспект Пролетарской Победы Ростикс", true); checkIsAltOrOldName("Ленинград проспект Пролетарской Победы Ростикс", true); } + +UNIT_CLASS_TEST(ProcessorTest, JaKanaNormalizationTest) +{ + string const countryName = "Wonderland"; + + TestPOI poiHiragana(m2::PointD(0.0, 0.0), "とうきょうと", "default"); + TestPOI poiKatakana(m2::PointD(1.0, 1.0), "トウキョウト", "default"); + + auto countryId = BuildCountry(countryName, [&](TestMwmBuilder & builder) { + builder.Add(poiHiragana); + builder.Add(poiKatakana); + }); + + SetViewport(m2::RectD(m2::PointD(0.0, 0.0), m2::PointD(1.0, 1.0))); + { + Rules rules = {ExactMatch(countryId, poiHiragana), ExactMatch(countryId, poiKatakana)}; + TEST(ResultsMatch("とうきょうと", rules), ()); + TEST(ResultsMatch("トウキョウト", rules), ()); + } +} } // namespace } // namespace search