[search] Test poi-poi parse.

This commit is contained in:
tatiana-yan 2020-05-18 12:50:42 +03:00 committed by mpimenov
parent abacd4e125
commit a86cbe05a5
5 changed files with 39 additions and 19 deletions

View file

@ -51,9 +51,10 @@ namespace search
// feature-from-parent-layer. Belongs-to is a partial relation on
// features, and has different meaning for different search classes:
//
// * BUILDING belongs-to STREET iff the building is located on the street;
// * BUILDING/POI/SUBPOI belongs-to STREET iff it is located on the street;
// * BUILDING belongs-to CITY iff the building is located in the city;
// * POI belongs-to BUILDING iff the poi is (roughly) located near or inside the building;
// * POI/SUBPOI belongs-to BUILDING iff the poi is (roughly) located near or inside the building;
// * SUBPOI belongs-to POI iff the poi is (roughly) located near or inside the building;
// * STREET belongs-to CITY iff the street is (roughly) located in the city;
// * etc.
//
@ -105,7 +106,7 @@ public:
break;
case Model::TYPE_SUBURB:
ASSERT(child.m_type == Model::TYPE_STREET || child.m_type == Model::TYPE_BUILDING ||
child.m_type == Model::TYPE_POI,
child.m_type == Model::TYPE_POI || child.m_type == Model::TYPE_SUBPOI,
());
// Avoid matching buildings to suburb without street.
if (child.m_type == Model::TYPE_BUILDING)

View file

@ -354,7 +354,7 @@ class RankerResultMaker
info.m_popularity = preInfo.m_popularity;
info.m_rating = preInfo.m_rating;
info.m_type = preInfo.m_type;
if (info.m_type == Model::TYPE_POI)
if (info.m_type == Model::TYPE_POI || info.m_type == Model::TYPE_SUBPOI)
info.m_resultType = GetResultType(feature::TypesHolder(ft));
info.m_allTokensUsed = preInfo.m_allTokensUsed;
info.m_numTokens = m_params.GetNumTokens();

View file

@ -254,7 +254,7 @@ double RankingInfo::GetLinearModelRank() const
result += kRating * rating;
result += m_falseCats * kFalseCats;
result += kType[m_type];
if (m_type == Model::TYPE_POI)
if (m_type == Model::TYPE_POI || m_type == Model::TYPE_SUBPOI)
result += kResultType[base::Underlying(m_resultType)];
result += kNameScore[nameScore];
result += kErrorsMade * GetErrorsMadePerToken();

View file

@ -93,7 +93,7 @@ struct RankingInfo
// Search type for the feature.
Model::Type m_type = Model::TYPE_COUNT;
// Type (food/transport/attraction/etc) for POI results for non-categorial requests.
// Type (food/transport/attraction/etc) for POI/SUBPOI results for non-categorial requests.
ResultType m_resultType = ResultType::Count;
// True if all of the tokens that the feature was matched by

View file

@ -1480,11 +1480,15 @@ UNIT_CLASS_TEST(ProcessorTest, PathsThroughLayers)
vector<m2::PointD>{m2::PointD{-16.0, -16.0}, m2::PointD(0.0, 0.0), m2::PointD(16.0, 16.0)},
"Computing street", "en");
TestBuilding statisticalLearningBuilding(m2::PointD(8.0, 8.0), "Statistical Learning, Inc.", "0",
TestBuilding statisticalLearningBuilding(m2::PointD(8.0, 8.0),
"Statistical Learning Buisiness Center", "0",
computingStreet.GetName("en"), "en");
TestPOI reinforcementCafe(m2::PointD(8.0, 8.0), "Trattoria Reinforcemento", "en");
reinforcementCafe.SetTypes({{"amenity", "cafe"}});
TestPOI supervisedOffice(m2::PointD(8.0, 8.0), "Supervised, Inc.", "en");
supervisedOffice.SetTypes({{"office", "company"}});
TestPOI svmCafe(m2::PointD(8.0, 8.0), "Trattoria SVM", "en");
svmCafe.SetTypes({{"amenity", "cafe"}});
BuildWorld([&](TestMwmBuilder & builder) {
builder.Add(scienceCountry);
@ -1495,7 +1499,8 @@ UNIT_CLASS_TEST(ProcessorTest, PathsThroughLayers)
auto countryId = BuildCountry(countryName, [&](TestMwmBuilder & builder) {
builder.Add(computingStreet);
builder.Add(statisticalLearningBuilding);
builder.Add(reinforcementCafe);
builder.Add(supervisedOffice);
builder.Add(svmCafe);
});
SetViewport(m2::RectD(m2::PointD(-100.0, -100.0), m2::PointD(100.0, 100.0)));
@ -1511,25 +1516,39 @@ UNIT_CLASS_TEST(ProcessorTest, PathsThroughLayers)
auto const ruleStreet = ExactMatch(countryId, computingStreet);
auto const ruleBuilding = ExactMatch(countryId, statisticalLearningBuilding);
auto const rulePoi = ExactMatch(countryId, reinforcementCafe);
auto const rulePoi = ExactMatch(countryId, supervisedOffice);
auto const ruleSubpoi = ExactMatch(countryId, svmCafe);
// POI-BUILDING-STREET
TEST(ResultsMatch("computing street statistical learning cafe ", {rulePoi, ruleStreet}), ());
TEST(ResultsMatch("computing street 0 cafe ", {rulePoi}), ());
// SUBPOI-POI-BUILDING-STREET
TEST(ResultsMatch("computing street 0 supervised cafe ", {ruleSubpoi}), ());
// POI-BUILDING is not supported
// SUBPOI-BUILDING-STREET / POI-BUILDING-STREET
TEST(ResultsMatch("computing street statistical learning cafe ", {ruleSubpoi, ruleStreet}), ());
TEST(ResultsMatch("computing street 0 cafe ", {ruleSubpoi}), ());
TEST(ResultsMatch("computing street statistical learning office ", {rulePoi, ruleStreet}), ());
TEST(ResultsMatch("computing street 0 office ", {rulePoi}), ());
// POI-BUILDING / SUBPOI-BUILDING is not supported
TEST(ResultsMatch("statistical learning cafe ", {}), ());
TEST(ResultsMatch("0 cafe ", {}), ());
TEST(ResultsMatch("statistical learning supervised ", {}), ());
TEST(ResultsMatch("0 office ", {}), ());
// POI-STREET
TEST(ResultsMatch("computing street cafe ", {rulePoi, ruleStreet}), ());
// POI-STREET / SUBPOI - STREET
TEST(ResultsMatch("computing street cafe ", {ruleSubpoi, ruleStreet}), ());
TEST(ResultsMatch("computing street office ", {rulePoi, ruleStreet}), ());
// BUILDING-STREET
TEST(ResultsMatch("computing street statistical learning ", {ruleBuilding, ruleStreet}), ());
TEST(ResultsMatch("computing street 0 ", {ruleBuilding}), ());
// POI
TEST(ResultsMatch("cafe ", {rulePoi}), ());
// POI / SUBPOI
TEST(ResultsMatch("cafe ", {ruleSubpoi}), ());
TEST(ResultsMatch("office ", {rulePoi}), ());
// POI-SUBPOI
TEST(ResultsMatch("supervised cafe ", {ruleSubpoi}), ());
TEST(ResultsMatch("supervised svm ", {ruleSubpoi}), ());
// BUILDING
TEST(ResultsMatch("statistical learning ", {ruleBuilding}), ());