diff options
author | vng <viktor.govako@gmail.com> | 2015-08-18 17:31:14 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:01:35 +0300 |
commit | 298a5965ee32eaabe97b671b262584a48fd8c33a (patch) | |
tree | 9db10ff1839650ed537f5222c6f7246ce26c0589 /indexer | |
parent | fb7e49b8285f92eb796a8a156461eeba5bbcbb83 (diff) |
[search] Ignore accents in string matching.
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/indexer_tests/search_string_utils_test.cpp | 3 | ||||
-rw-r--r-- | indexer/search_string_utils.hpp | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/indexer/indexer_tests/search_string_utils_test.cpp b/indexer/indexer_tests/search_string_utils_test.cpp index 26ed3b52e7..10d92a9c59 100644 --- a/indexer/indexer_tests/search_string_utils_test.cpp +++ b/indexer/indexer_tests/search_string_utils_test.cpp @@ -31,7 +31,8 @@ UNIT_TEST(NormalizeAndSimplifyStringWithOurTambourines) "バス", "ハス", "âàáạăốợồôểềệếỉđưựứửýĂÂĐÊÔƠƯ", "aaaaaooooeeeeiduuuuyaadeoou", // Vietnamese - "ăâț", "aat" // Romanian + "ăâț", "aat", // Romanian + "Триу́мф-Пала́с", "триумф-палас", // Russian accent }; for (size_t i = 0; i < ARRAY_SIZE(arr); i += 2) diff --git a/indexer/search_string_utils.hpp b/indexer/search_string_utils.hpp index 86c9b10092..f131bb73a4 100644 --- a/indexer/search_string_utils.hpp +++ b/indexer/search_string_utils.hpp @@ -46,6 +46,15 @@ inline strings::UniString NormalizeAndSimplifyString(string const & s) MakeLowerCaseInplace(uniString); NormalizeInplace(uniString); + + // Remove accents that can appear after NFKD normalization. + uniString.erase_if([](UniChar const & c) + { + // ̀ COMBINING GRAVE ACCENT + // ́ COMBINING ACUTE ACCENT + return (c == 0x0300 || c == 0x0301); + }); + return uniString; /// @todo Restore this logic to distinguish и-й in future. |