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

booking_addr_match.cpp « booking_quality_check « generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e638dbf0c9e3ec03f5fe10a1b2789ef23d240d0d (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "generator/booking_dataset.hpp"
#include "generator/osm_source.hpp"

#include "map/framework.hpp"

#include "search/processor_factory.hpp"
#include "search/ranking_info.hpp"
#include "search/result.hpp"
#include "search/search_quality/helpers.hpp"
#include "search/search_tests_support/test_search_engine.hpp"
#include "search/search_tests_support/test_search_request.hpp"

#include "indexer/classificator_loader.hpp"
#include "indexer/data_header.hpp"
#include "indexer/index.hpp"
#include "indexer/mwm_set.hpp"

#include "storage/country_info_getter.hpp"
#include "storage/index.hpp"
#include "storage/storage.hpp"

#include "coding/reader_wrapper.hpp"

#include "geometry/distance_on_sphere.hpp"

#include "platform/country_file.hpp"
#include "platform/local_country_file.hpp"
#include "platform/local_country_file_utils.hpp"
#include "platform/platform.hpp"

#include "std/fstream.hpp"
#include "std/iostream.hpp"
#include "std/numeric.hpp"
#include "std/shared_ptr.hpp"

#include "3party/gflags/src/gflags/gflags.h"

using namespace generator;
using namespace storage;
using namespace search;
using namespace search::tests_support;

DEFINE_string(booking_data, "", "Path to booking data in .tsv format");
DEFINE_string(user_resource_path, "", "Path to data directory (resources dir)");
DEFINE_string(data_path, "", "Path to mwm files (writable dir)");
DEFINE_string(locale, "en", "Locale of all the search queries");
DEFINE_int32(num_threads, 1, "Number of search engine threads");

int main(int argc, char * argv[])
{
  google::SetUsageMessage(
      "Takes OSM XML data from stdin and creates"
      " data and index files in several passes.");
  google::ParseCommandLineFlags(&argc, &argv, true);

  Platform & platform = GetPlatform();

  string countriesFile = COUNTRIES_FILE;
  if (!FLAGS_user_resource_path.empty())
  {
    platform.SetResourceDir(FLAGS_user_resource_path);
    countriesFile = my::JoinFoldersToPath(FLAGS_user_resource_path, COUNTRIES_FILE);
  }

  if (!FLAGS_data_path.empty())
  {
    platform.SetSettingsDirForTests(FLAGS_data_path);
    platform.SetWritableDirForTests(FLAGS_data_path);
  }

  LOG(LINFO, ("writable dir =", platform.WritableDir()));
  LOG(LINFO, ("resources dir =", platform.ResourcesDir()));

  LOG_SHORT(LINFO, ("Booking data:", FLAGS_booking_data));

  BookingDataset bookingDataset(FLAGS_booking_data);
  BookingDataset::AddressMatcher addressMatcher;

  size_t matchedNum = 0;
  size_t emptyAddr = 0;
  for (size_t i = 0; i < bookingDataset.Size(); ++i)
  {
    BookingDataset::Hotel & hotel = bookingDataset.GetHotel(i);

    addressMatcher(hotel);

    if (hotel.address.empty())
      ++emptyAddr;

    if (hotel.HasAddresParts())
    {
      ++matchedNum;
      cout << "[" << i << "/" << bookingDataset.Size() << "] Hotel: " << hotel.address
           << " AddLoc: " << hotel.translations << " --> " << hotel.street << " "
           << hotel.houseNumber << endl;
    }
  }

  cout << "Num of hotels: " << bookingDataset.Size() << " matched: " << matchedNum
       << " Empty addresses: " << emptyAddr << endl;

  return 0;
}