[search] Conform kCategoriesHasName with kViewportDiffThreshold.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako 2024-10-19 13:54:04 -03:00 committed by Viktor Havaka
parent eb53e65cda
commit acc198b748
2 changed files with 30 additions and 3 deletions

View file

@ -20,7 +20,7 @@ namespace
{
// See search/search_quality/scoring_model.py for details. In short,
// these coeffs correspond to coeffs in a linear model.
double constexpr kHasName = 0.5;
double constexpr kCategoriesHasName = 0.25;
double constexpr kCategoriesPopularity = 0.05;
double constexpr kCategoriesDistanceToPivot = -0.6874177;
double constexpr kCategoriesRank = 1.0000000;
@ -115,7 +115,7 @@ static_assert(std::size(kStreetType) == base::Underlying(StreetType::Count));
static_assert(kType[Model::TYPE_BUILDING] > kStreetType[StreetType::Motorway]);
// Coeffs sanity checks.
static_assert(kHasName >= 0, "");
static_assert(kCategoriesHasName >= 0 && kCategoriesHasName < kViewportDiffThreshold);
static_assert(kCategoriesPopularity >= 0, "");
static_assert(kDistanceToPivot <= 0, "");
static_assert(kRank >= 0, "");
@ -417,7 +417,7 @@ double RankingInfo::GetLinearModelRank(bool viewportMode /* = false */) const
if (m_falseCats)
result += kCategoriesFalseCats;
if (m_hasName)
result += kHasName;
result += kCategoriesHasName;
}
// Trying to fix https://github.com/organicmaps/organicmaps/issues/5251.

View file

@ -1268,6 +1268,33 @@ UNIT_CLASS_TEST(MwmTestsFixture, PostOffice_Viewport)
}
}
UNIT_CLASS_TEST(MwmTestsFixture, Family_Viewport)
{
using namespace mercator;
auto const & cl = classif();
// Buenos Aires
ms::LatLon const center(-34.588943, -58.3988512);
SetViewportAndLoadMaps(center);
auto params = GetDefaultSearchParams("Family holiday ");
params.m_mode = search::Mode::Viewport;
params.m_categorialRequest = true;
params.m_maxNumResults = search::SearchParams::kDefaultNumResultsInViewport;
{
params.m_viewport = { LonToX(-58.4015885), LatToY(-34.5901233), LonToX(-58.396118), LatToY(-34.5876888) };
auto request = MakeRequest(params);
auto const & results = request->Results();
Range allRange(results, true /* all */);
TEST_EQUAL(CountClassifType(allRange, cl.GetTypeByPath({"shop", "baby_goods"})), 1, ());
TEST_EQUAL(CountClassifType(allRange, cl.GetTypeByPath({"shop", "toys"})), 1, ());
TEST_EQUAL(CountClassifType(allRange, cl.GetTypeByPath({"leisure", "playground"})), 2, ());
}
}
UNIT_CLASS_TEST(MwmTestsFixture, NotAllTokens)
{
auto const & cl = classif();