diff --git a/indexer/search_string_utils.cpp b/indexer/search_string_utils.cpp index 7ded9149e9..6f32e2a950 100644 --- a/indexer/search_string_utils.cpp +++ b/indexer/search_string_utils.cpp @@ -30,6 +30,9 @@ std::vector const kAllowedMisprints = { MakeUniString("ао"), MakeUniString("еиэ"), MakeUniString("шщ"), + // Spanish + MakeUniString("jh"), // "Jose" <-> "Hose" + MakeUniString("fh"), // "Hernández" <-> "Fernández" }; std::pair const kPreprocessReplacements[] = { diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 8bf5998de9..885622a04b 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -559,7 +559,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_PureCategory) } } -UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_ErrorsMade) +UNIT_CLASS_TEST(ProcessorTest, RankingInfo_ErrorsMade_1) { TestCity chekhov({0, 0}, "Чеховъ Антонъ Павловичъ", "ru", 100 /* rank */); @@ -605,6 +605,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_ErrorsMade) checkErrors("Cafe Yesenina", ErrorsMade(0)); checkErrors("Cafe Jesenina", ErrorsMade(1)); + /// @see search_string_utils.cpp, kAllowedMisprints // We allow only Y->{E, J, I, U} misprints for the first letter. checkErrors("Cafe Esenina", ErrorsMade(2)); @@ -634,6 +635,33 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_ErrorsMade) checkErrors("лермонтов чеховъ антон павлович", ErrorsMade(2)); } +// https://github.com/organicmaps/organicmaps/issues/5296 +UNIT_CLASS_TEST(ProcessorTest, RankingInfo_ErrorsMade_2) +{ + TestStreet hernandes({{-0.5, -0.5}, {0, 0}, {0.5, 0.5}}, "José Hernández", "es"); + + auto wonderlandId = BuildCountry("Wonderland", [&](TestMwmBuilder & builder) + { + builder.Add(hernandes); + }); + + SetViewport(m2::RectD(-1, -1, 1, 1)); + + auto checkErrors = [&](string const & query, ErrorsMade const & errorsMade) + { + auto request = MakeRequest(query, "es"); + auto const & results = request->Results(); + + Rules rules{ExactMatch(wonderlandId, hernandes)}; + TEST(ResultsMatch(results, rules), (query)); + TEST_EQUAL(results.size(), 1, (query)); + TEST_EQUAL(results[0].GetRankingInfo().m_errorsMade, errorsMade, (query)); + }; + + checkErrors("Hose", ErrorsMade(1)); + checkErrors("Fernández", ErrorsMade(1)); +} + UNIT_CLASS_TEST(ProcessorTest, TestHouseNumbers) { TestCity greenCity({0, 0}, "Зеленоград", "ru", 100 /* rank */);