blob: 6919b3dc06519c038f5fe9f61ab7e6e1badc8dee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#pragma once
#include "search/geocoder_locality.hpp"
#include "search/ranking_utils.hpp"
#include <cstdint>
#include <string>
#include <vector>
namespace search
{
class CBV;
class QueryParams;
struct BaseContext;
class LocalityScorer
{
public:
static size_t const kDefaultReadLimit;
class Delegate
{
public:
virtual ~Delegate() = default;
virtual void GetNames(uint32_t featureId, std::vector<std::string> & names) const = 0;
virtual uint8_t GetRank(uint32_t featureId) const = 0;
};
LocalityScorer(QueryParams const & params, Delegate const & delegate);
// Leaves at most |limit| elements of |localities|, ordered by their
// features.
void GetTopLocalities(MwmSet::MwmId const & countryId, BaseContext const & ctx,
CBV const & filter, size_t limit, std::vector<Locality> & localities);
private:
struct ExLocality
{
ExLocality();
explicit ExLocality(Locality const & locality);
inline uint32_t GetId() const { return m_locality.m_featureId; }
Locality m_locality;
size_t m_numTokens;
uint8_t m_rank;
NameScore m_nameScore;
};
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.
void LeaveTopLocalities(size_t limit, std::vector<Locality> & localities) const;
void RemoveDuplicates(std::vector<ExLocality> & ls) const;
void LeaveTopByRankAndProb(size_t limit, std::vector<ExLocality> & ls) const;
void SortByNameAndProb(std::vector<ExLocality> & ls) const;
QueryParams const & m_params;
Delegate const & m_delegate;
};
} // namespace search
|