forked from organicmaps/organicmaps
[search] Index "strasse" both together and separately with street name
This commit is contained in:
parent
9ee654b5c0
commit
1e4abcf099
2 changed files with 58 additions and 0 deletions
|
@ -153,6 +153,29 @@ struct FeatureNameInserter
|
|||
m_keyValuePairs.emplace_back(key, m_val);
|
||||
}
|
||||
|
||||
void AddStrasseNames(signed char lang, search::QueryTokens const & tokens) const
|
||||
{
|
||||
auto static const kStrasse = strings::MakeUniString("strasse");
|
||||
for (size_t i = 0; i < tokens.size(); ++i)
|
||||
{
|
||||
auto const & token = tokens[i];
|
||||
|
||||
if (!strings::EndsWith(token, kStrasse))
|
||||
continue;
|
||||
|
||||
if (token == kStrasse)
|
||||
{
|
||||
if (i != 0)
|
||||
AddToken(lang, tokens[i - 1] + kStrasse);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const name = strings::UniString(token.begin(), token.end() - kStrasse.size());
|
||||
AddToken(lang, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(signed char lang, string const & name) const
|
||||
{
|
||||
strings::UniString const uniName = search::NormalizeAndSimplifyString(name);
|
||||
|
@ -186,6 +209,8 @@ struct FeatureNameInserter
|
|||
});
|
||||
for (auto const & token : tokens)
|
||||
filter.Put(token, false /* isPrefix */, 0 /* tag */);
|
||||
|
||||
AddStrasseNames(lang, tokens);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1964,5 +1964,38 @@ UNIT_CLASS_TEST(ProcessorTest, StreetSynonymPrefix)
|
|||
TEST(ResultsMatch("3 Boulevard Maloney Est", rules), ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(ProcessorTest, StrasseIndexing)
|
||||
{
|
||||
string const countryName = "Wonderland";
|
||||
|
||||
TestStreet s1(vector<m2::PointD>{m2::PointD(-1.0, -1.0), m2::PointD(1.0, 1.0)}, "abcdstraße",
|
||||
"en");
|
||||
TestStreet s2(vector<m2::PointD>{m2::PointD(1.0, -1.0), m2::PointD(-1.0, 1.0)}, "xyz strasse",
|
||||
"en");
|
||||
|
||||
auto countryId = BuildCountry(countryName, [&](TestMwmBuilder & builder) {
|
||||
builder.Add(s1);
|
||||
builder.Add(s2);
|
||||
});
|
||||
|
||||
SetViewport(m2::RectD(m2::PointD(0.0, 0.0), m2::PointD(1.0, 2.0)));
|
||||
{
|
||||
Rules rules = {ExactMatch(countryId, s1)};
|
||||
TEST(ResultsMatch("abcdstrasse", rules), ());
|
||||
TEST(ResultsMatch("abcdstraße", rules), ());
|
||||
TEST(ResultsMatch("abcd strasse", rules), ());
|
||||
TEST(ResultsMatch("abcd straße", rules), ());
|
||||
TEST(ResultsMatch("abcd", rules), ());
|
||||
}
|
||||
{
|
||||
Rules rules = {ExactMatch(countryId, s2)};
|
||||
TEST(ResultsMatch("xyzstrasse", rules), ());
|
||||
TEST(ResultsMatch("xyzstraße", rules), ());
|
||||
TEST(ResultsMatch("xyz strasse", rules), ());
|
||||
TEST(ResultsMatch("xyz straße", rules), ());
|
||||
TEST(ResultsMatch("xyz", rules), ());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace search
|
||||
|
|
Loading…
Add table
Reference in a new issue