[search] StreetTokensFilter: do not emit delayed token for incomplete street synonym.

This commit is contained in:
tatiana-yan 2019-06-21 12:54:08 +03:00 committed by mpimenov
parent b7863c9537
commit 5d7cc1b011
2 changed files with 27 additions and 1 deletions

View file

@ -361,7 +361,9 @@ void StreetTokensFilter::Put(strings::UniString const & token, bool isPrefix, si
m_delayedTag = tag;
return;
}
if (m_numSynonyms == 2)
// Do not emit delayed token for incomplete street synonym.
if ((!isPrefix || IsStreetSynonym(token)) && m_numSynonyms == 2)
EmitToken(m_delayedToken, m_delayedTag);
}
EmitToken(token, tag);

View file

@ -1940,5 +1940,29 @@ UNIT_CLASS_TEST(ProcessorTest, ExactMatchTest)
TEST(results[1].GetRankingInfo().m_exactMatch, ());
}
}
UNIT_CLASS_TEST(ProcessorTest, StreetSynonymPrefix)
{
string const countryName = "Wonderland";
// Est is a prefix of "estrada".
TestStreet street(vector<m2::PointD>{m2::PointD(-1.0, -1.0), m2::PointD(1.0, 1.0)},
"Boulevard Maloney Est", "en");
TestPOI house(m2::PointD(1.0, 1.0), "", "en");
house.SetHouseNumber("3");
house.SetStreetName(street.GetName("en"));
auto countryId = BuildCountry(countryName, [&](TestMwmBuilder & builder) {
builder.Add(street);
builder.Add(house);
});
SetViewport(m2::RectD(m2::PointD(0.0, 0.0), m2::PointD(1.0, 2.0)));
{
Rules rules = {ExactMatch(countryId, house)};
TEST(ResultsMatch("3 Boulevard Maloney Est", rules), ());
}
}
} // namespace
} // namespace search