From 232d898ed5d4328c364dc353ab79c09077984546 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Tue, 21 Apr 2020 10:47:05 +0300 Subject: [PATCH] Review fixes. --- search/locality_scorer.hpp | 8 +++++--- search/search_tests/locality_scorer_test.cpp | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/search/locality_scorer.hpp b/search/locality_scorer.hpp index a5da0d0097..1ed57d66dc 100644 --- a/search/locality_scorer.hpp +++ b/search/locality_scorer.hpp @@ -37,7 +37,7 @@ public: LocalityScorer(QueryParams const & params, m2::PointD const & pivot, Delegate & delegate); - void SetPivotForTests(m2::PointD const & pivot) { m_pivot = pivot; } + void SetPivotForTesting(m2::PointD const & pivot) { m_pivot = pivot; } // Leaves at most |limit| elements of |localities|, ordered by their // features. @@ -60,8 +60,10 @@ private: friend std::string DebugPrint(ExLocality const & locality); - // Leaves at most |limit| elements of |localities|, ordered by some - // combination of ranks and number of matched tokens. + // Leaves at most |limit| elements of |localities|. Candidates are selected with + // LeaveTopByExactMatchNormAndRank. Number of candidates typically is much bigger than |limit| + // (100 vs 5). Then final localities are selected from candidates with + // LeaveTopBySimilarityAndOther. void LeaveTopLocalities(IdfMap & idfs, size_t limit, std::vector & localities); // Selects at most |limitUniqueIds| best features by exact match, query norm and diff --git a/search/search_tests/locality_scorer_test.cpp b/search/search_tests/locality_scorer_test.cpp index feb377748c..01dbf55b4e 100644 --- a/search/search_tests/locality_scorer_test.cpp +++ b/search/search_tests/locality_scorer_test.cpp @@ -48,7 +48,7 @@ public: { m_params.Clear(); - m_scorer.SetPivotForTests(pivot); + m_scorer.SetPivotForTesting(pivot); vector tokens; Delimiters delims; @@ -296,11 +296,11 @@ UNIT_CLASS_TEST(LocalityScorerTest, DistanceToPivot) AddLocality("Aberdeen", ID_ABERDEEN_CLOSE, 10 /* rank */, m2::PointD(11.0, 11.0)); AddLocality("Aberdeen", ID_ABERDEEN_RANK1, 100 /* rank */, m2::PointD(0.0, 0.0)); AddLocality("Aberdeen", ID_ABERDEEN_RANK2, 50 /* rank */, m2::PointD(2.0, 2.0)); - AddLocality("Aberdeen", ID_ABERDEEN_RANK2, 5 /* rank */, m2::PointD(4.0, 4.0)); + AddLocality("Aberdeen", ID_ABERDEEN_RANK3, 5 /* rank */, m2::PointD(4.0, 4.0)); InitParams("Aberdeen", m2::PointD(10.0, 10.0) /* pivot */, false /* lastTokenIsPrefix */); - // Expected order is: the closest one (ID_ABERDEEN_CLOSE) first, than sorted by rank. + // Expected order is: the closest one (ID_ABERDEEN_CLOSE) first, then sorted by rank. TEST_EQUAL(GetTopLocalities(1 /* limit */), Ids({ID_ABERDEEN_CLOSE}), ()); TEST_EQUAL(GetTopLocalities(2 /* limit */), Ids({ID_ABERDEEN_CLOSE, ID_ABERDEEN_RANK1}), ()); TEST_EQUAL(GetTopLocalities(3 /* limit */),