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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'search/ranking_utils.cpp')
-rw-r--r--search/ranking_utils.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/search/ranking_utils.cpp b/search/ranking_utils.cpp
new file mode 100644
index 0000000000..39dcf2fe7f
--- /dev/null
+++ b/search/ranking_utils.cpp
@@ -0,0 +1,41 @@
+#include "search/ranking_utils.hpp"
+
+#include "std/algorithm.hpp"
+
+using namespace strings;
+
+namespace search
+{
+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 search