diff options
author | Kirill Zhdanovich <kzhdanovich@gmail.com> | 2014-03-18 18:47:12 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:13:41 +0300 |
commit | 87a6919eba38a027cf8f76e6746cb9af1397c0a2 (patch) | |
tree | 116f51fd00ac0605468d2a9e5c5b849c750ff72c /indexer/feature_impl.cpp | |
parent | e415ecf4577f26b84c1e40f8a38dead2412a64e1 (diff) |
[search] house number recognition
Diffstat (limited to 'indexer/feature_impl.cpp')
-rw-r--r-- | indexer/feature_impl.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/indexer/feature_impl.cpp b/indexer/feature_impl.cpp index bcac11206c..16e2c73aec 100644 --- a/indexer/feature_impl.cpp +++ b/indexer/feature_impl.cpp @@ -1,6 +1,7 @@ #include "feature_impl.hpp" #include "../base/string_utils.hpp" +#include "../base/logging.hpp" namespace feature @@ -22,12 +23,43 @@ bool IsNumber(strings::UniString const & s) return true; } -/// Check that token can be house number. -bool IsHouseNumber(strings::UniString const & s) +bool IsStreetNumber(strings::UniString const & s) +{ + size_t count = s.size(); + if (count >= 2) + { + /// add different localities in future, if it's a problem. + string streetEndings [] = {"st", "nd", "rd", "th"}; + for (size_t i = 0; i < ARRAY_SIZE(streetEndings); ++i) + { + size_t start = count - streetEndings[i].size(); + bool flag = false; + for (size_t j = 0; j < streetEndings[i].size(); ++j) + { + if (streetEndings[i][j] != s[start + j]) + { + flag = true; + break; + } + } + if (flag) + return false; + } + return true; + } + return false; +} + +bool IsHouseNumberDeepCheck(strings::UniString const & s) { size_t const count = s.size(); - /// @todo Probably, call some check function from House:: - return (count > 0 && count < 8 && IsDigit(s[0])); + if (count == 0) + return false; + if (!IsDigit(s[0])) + return false; + if (IsStreetNumber(s)) + return false; + return (count < 8); } bool IsHouseNumber(string const & s) |