Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ranking_utils.cpp « v2 « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f865f3336eb3d5707be167164be595902ee3d22d (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
#include "search/v2/ranking_utils.hpp"

#include "std/algorithm.hpp"

using namespace strings;

namespace search
{
namespace v2
{
namespace impl
{
bool Match(vector<UniString> const & tokens, UniString const & token)
{
  return find(tokens.begin(), tokens.end(), token) != tokens.end();
}

bool PrefixMatch(vector<UniString> const & prefixes, UniString const & token)
{
  for (auto const & prefix : prefixes)
  {
    if (StartsWith(token, prefix))
      return true;
  }
  return false;
}
}  // namespace impl

string DebugPrint(NameScore score)
{
  switch (score)
  {
  case NAME_SCORE_ZERO: return "Zero";
  case NAME_SCORE_SUBSTRING_PREFIX: return "Substring Prefix";
  case NAME_SCORE_SUBSTRING: return "Substring";
  case NAME_SCORE_FULL_MATCH_PREFIX: return "Full Match Prefix";
  case NAME_SCORE_FULL_MATCH: return "Full Match";
  case NAME_SCORE_COUNT: return "Count";
  }
  return "Unknown";
}
}  // namespace v2
}  // namespace search