Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-02-10 14:52:45 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:33:57 +0300
commit5fb210516eb607489b7f415248ef3999832c2eb5 (patch)
tree82174147349bc98d83afc1d959a6e1482420ac65 /indexer/search_index_builder.cpp
parent467169ad30829cffad793a46d17360b155fc6751 (diff)
[search] Skip features without names, that has place-city (town, region) types, in suggestion trie generation.
Diffstat (limited to 'indexer/search_index_builder.cpp')
-rw-r--r--indexer/search_index_builder.cpp56
1 files changed, 55 insertions, 1 deletions
diff --git a/indexer/search_index_builder.cpp b/indexer/search_index_builder.cpp
index 2b327c26db..5d47d063ff 100644
--- a/indexer/search_index_builder.cpp
+++ b/indexer/search_index_builder.cpp
@@ -6,6 +6,7 @@
#include "search_trie.hpp"
#include "search_string_utils.hpp"
#include "string_file.hpp"
+#include "classificator.hpp"
#include "../defines.hpp"
@@ -43,6 +44,8 @@ struct FeatureNameInserter
buffer_vector<strings::UniString, 32> tokens;
SplitUniString(uniName, MakeBackInsertFunctor(tokens), search::Delimiters());
+
+ /// @todo MAX_TOKENS = 32, in Query::Search we use 31 + prefix. Why 30 ???
if (tokens.size() > 30)
{
LOG(LWARNING, ("Name has too many tokens:", name));
@@ -80,6 +83,49 @@ class FeatureInserter
m_valueSaver.Save(sink, v);
}
+ class AvoidEmptyName
+ {
+ vector<uint32_t> m_vec;
+
+ public:
+ AvoidEmptyName()
+ {
+ char const * arr[][3] = {
+ { "place", "city", ""},
+ { "place", "city", "capital"},
+ { "place", "town", ""},
+ { "place", "county", ""},
+ { "place", "state", ""},
+ { "place", "region", ""}
+ };
+
+ Classificator const & c = classif();
+
+ size_t const count = ARRAY_SIZE(arr);
+ m_vec.reserve(count);
+
+ for (size_t i = 0; i < count; ++i)
+ {
+ vector<string> v;
+ v.push_back(arr[i][0]);
+ v.push_back(arr[i][1]);
+ if (strlen(arr[i][2]) > 0)
+ v.push_back(arr[i][2]);
+
+ m_vec.push_back(c.GetTypeByPath(v));
+ }
+ }
+
+ bool IsExist(feature::TypesHolder const & types) const
+ {
+ for (size_t i = 0; i < m_vec.size(); ++i)
+ if (types.Has(m_vec[i]))
+ return true;
+
+ return false;
+ }
+ };
+
public:
FeatureInserter(StringsFile & names, serial::CodingParams const & cp)
: m_names(names), m_valueSaver(cp)
@@ -95,7 +141,15 @@ public:
MakeValue(f, types, pos, inserter.m_val);
// add names of the feature
- f.ForEachNameRef(inserter);
+ if (!f.ForEachNameRef(inserter))
+ {
+ static AvoidEmptyName check;
+ if (check.IsExist(types))
+ {
+ // Do not add such features without names to suggestion list.
+ return;
+ }
+ }
// add names of categories of the feature
for (size_t i = 0; i < types.Size(); ++i)