forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
ba145c115d
commit
38db712a88
5 changed files with 22 additions and 30 deletions
|
@ -104,7 +104,8 @@ void GetCategoryTypes(CategoriesHolder const & categories, pair<int, int> const
|
|||
for (uint32_t t : types)
|
||||
{
|
||||
// Leave only 2 levels of types - for example, do not distinguish:
|
||||
// highway-primary-bridge or amenity-parking-fee.
|
||||
// highway-primary-bridge and highway-primary-tunnel
|
||||
// or amenity-parking-fee and amenity-parking-underground-fee.
|
||||
ftype::TruncValue(t, 2);
|
||||
|
||||
// Only categorized types will be added to index.
|
||||
|
@ -130,11 +131,9 @@ struct FeatureNameInserter
|
|||
bool m_hasStreetType;
|
||||
|
||||
FeatureNameInserter(SynonymsHolder * synonyms, vector<pair<TKey, TValue>> & keyValuePairs,
|
||||
vector<uint32_t> const & categoryTypes)
|
||||
: m_synonyms(synonyms), m_keyValuePairs(keyValuePairs)
|
||||
bool hasStreetType)
|
||||
: m_synonyms(synonyms), m_keyValuePairs(keyValuePairs), m_hasStreetType(hasStreetType)
|
||||
{
|
||||
auto const & streetChecker = ftypes::IsStreetChecker::Instance();
|
||||
m_hasStreetType = streetChecker(categoryTypes);
|
||||
}
|
||||
|
||||
void AddToken(signed char lang, strings::UniString const & s) const
|
||||
|
@ -178,22 +177,22 @@ public:
|
|||
// "street" in the categories branch of the search index.
|
||||
// However, we still add it when there are two or more street tokens
|
||||
// ("industrial st", "улица набережная").
|
||||
size_t numStreets = 0;
|
||||
size_t numStreetTokens = 0;
|
||||
vector<bool> isStreet(tokens.size());
|
||||
for (size_t i = 0; i < tokens.size(); ++i)
|
||||
{
|
||||
if (search::IsStreetSynonym(strings::ToUtf8(tokens[i])))
|
||||
if (search::IsStreetSynonym(tokens[i]))
|
||||
{
|
||||
isStreet[i] = true;
|
||||
++numStreets;
|
||||
++numStreetTokens;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < tokens.size(); ++i)
|
||||
{
|
||||
if (numStreets == 1 && isStreet[i] && m_hasStreetType)
|
||||
if (numStreetTokens == 1 && isStreet[i] && m_hasStreetType)
|
||||
{
|
||||
LOG(LDEBUG, ("skipping street:", name));
|
||||
LOG(LDEBUG, ("skipping token:", tokens[i], "in", name));
|
||||
continue;
|
||||
}
|
||||
AddToken(lang, tokens[i]);
|
||||
|
@ -268,13 +267,13 @@ public:
|
|||
if (types.Empty())
|
||||
return;
|
||||
|
||||
vector<uint32_t> categoryTypes;
|
||||
GetCategoryTypes(m_categories, m_scales, types, categoryTypes);
|
||||
auto const & streetChecker = ftypes::IsStreetChecker::Instance();
|
||||
bool hasStreetType = streetChecker(types);
|
||||
|
||||
// Init inserter with serialized value.
|
||||
// Insert synonyms only for countries and states (maybe will add cities in future).
|
||||
FeatureNameInserter<TKey, TValue> inserter(
|
||||
skipIndex.IsCountryOrState(types) ? m_synonyms : nullptr, m_keyValuePairs, categoryTypes);
|
||||
skipIndex.IsCountryOrState(types) ? m_synonyms : nullptr, m_keyValuePairs, hasStreetType);
|
||||
m_valueBuilder.MakeValue(f, types, index, inserter.m_val);
|
||||
|
||||
// Skip types for features without names.
|
||||
|
@ -285,7 +284,7 @@ public:
|
|||
|
||||
Classificator const & c = classif();
|
||||
|
||||
categoryTypes.clear();
|
||||
vector<uint32_t> categoryTypes;
|
||||
GetCategoryTypes(m_categories, m_scales, types, categoryTypes);
|
||||
|
||||
// add names of categories of the feature
|
||||
|
|
|
@ -49,6 +49,8 @@ class TestSearchQueryFactory : public search::SearchQueryFactory
|
|||
|
||||
UNIT_TEST(SearchQueryV2_Smoke)
|
||||
{
|
||||
my::g_LogLevel = LDEBUG;
|
||||
|
||||
classificator::Load();
|
||||
Platform & platform = GetPlatform();
|
||||
platform::LocalCountryFile wonderland(platform.WritableDir(), platform::CountryFile("wonderland"),
|
||||
|
|
|
@ -5,13 +5,7 @@
|
|||
|
||||
#include "base/macros.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
string NormalizeAndSimplifyRawString(char const * s)
|
||||
{
|
||||
return strings::ToUtf8(search::NormalizeAndSimplifyString(s));
|
||||
}
|
||||
} // namespace
|
||||
char const * STREET_TOKENS_SEPARATOR = "\t -,.";
|
||||
|
||||
strings::UniString search::FeatureTypeToString(uint32_t type)
|
||||
{
|
||||
|
@ -19,9 +13,6 @@ strings::UniString search::FeatureTypeToString(uint32_t type)
|
|||
return strings::UniString(s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
char const * STREET_TOKENS_SEPARATOR = "\t -,.";
|
||||
|
||||
/// @todo Move prefixes, suffixes into separate file (autogenerated).
|
||||
/// "Набережная" улица встречается в городах
|
||||
|
||||
|
@ -114,10 +105,10 @@ void search::GetStreetNameAsKey(string const & name, string & res)
|
|||
GetStreetName(iter, res);
|
||||
}
|
||||
|
||||
bool search::IsStreetSynonym(string const & s)
|
||||
bool search::IsStreetSynonym(strings::UniString const & s)
|
||||
{
|
||||
static unordered_set<string> const kSynonyms(
|
||||
make_transform_iterator(affics, &NormalizeAndSimplifyRawString),
|
||||
make_transform_iterator(affics + ARRAY_SIZE(affics), &NormalizeAndSimplifyRawString));
|
||||
static set<strings::UniString> const kSynonyms(
|
||||
make_transform_iterator(affics, &search::NormalizeAndSimplifyString),
|
||||
make_transform_iterator(affics + ARRAY_SIZE(affics), &search::NormalizeAndSimplifyString));
|
||||
return kSynonyms.count(s) != 0;
|
||||
}
|
||||
|
|
|
@ -114,5 +114,5 @@ bool TokenizeStringAndCheckIfLastTokenIsPrefix(string const & s,
|
|||
void GetStreetName(strings::SimpleTokenizer iter, string & streetName);
|
||||
void GetStreetNameAsKey(string const & name, string & res);
|
||||
|
||||
bool IsStreetSynonym(string const & s);
|
||||
bool IsStreetSynonym(strings::UniString const & s);
|
||||
} // namespace search
|
||||
|
|
|
@ -430,7 +430,7 @@ void Geocoder::GreedilyMatchStreets()
|
|||
size_t curToken = startToken;
|
||||
for (; curToken < m_numTokens && !m_usedTokens[curToken]; ++curToken)
|
||||
{
|
||||
if (IsStreetSynonym(strings::ToUtf8(m_params.GetTokens(curToken).front())))
|
||||
if (IsStreetSynonym(m_params.GetTokens(curToken).front()))
|
||||
continue;
|
||||
if (startToken == curToken || coding::CompressedBitVector::IsEmpty(allFeatures))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue