<commit_before>#include "search/integration_tests/test_mwm_builder.hpp"

#include "indexer/classificator.hpp"
#include "indexer/data_header.hpp"
#include "indexer/index_builder.hpp"
#include "indexer/search_index_builder.hpp"

#include "generator/feature_builder.hpp"
#include "generator/feature_generator.hpp"
#include "generator/feature_sorter.hpp"

#include "platform/local_country_file.hpp"

#include "base/logging.hpp"

#include "defines.hpp"

TestMwmBuilder::TestMwmBuilder(platform::LocalCountryFile & file)
    : m_file(file),
      m_collector(
          make_unique<feature::FeaturesCollector>(file.GetPath(MapOptions::Map) + EXTENSION_TMP)),
      m_classificator(classif())
{
}

TestMwmBuilder::~TestMwmBuilder()
{
  if (m_collector)
    Finish();
  CHECK(!m_collector, ("Features weren't dumped on disk."));
}

void TestMwmBuilder::AddPOI(m2::PointD const & p, string const & name, string const & lang)
{
  CHECK(m_collector, ("It's not possible to add features after call to Finish()."));
  FeatureBuilder1 fb;
  fb.SetCenter(p);
  fb.SetType(m_classificator.GetTypeByPath({"shop", "alcohol"}));
  CHECK(fb.AddName(lang, name), ("Can't set feature name:", name, "(", lang, ")"));
  (*m_collector)(fb);
}

void TestMwmBuilder::Finish()
{
  CHECK(m_collector, ("Finish() already was called."));
  m_collector.reset();
  feature::GenerateInfo info;
  info.m_targetDir = m_file.GetDirectory();
  info.m_tmpDir = m_file.GetDirectory();
  CHECK(GenerateFinalFeatures(info, m_file.GetCountryFile().GetNameWithoutExt(),
                              feature::DataHeader::country),
        ("Can't sort features."));
  CHECK(indexer::BuildIndexFromDatFile(m_file.GetPath(MapOptions::Map),
                                       m_file.GetPath(MapOptions::Map)),
        ("Can't build geometry index."));
  CHECK(indexer::BuildSearchIndexFromDatFile(m_file.GetPath(MapOptions::Map),
                                             true /* forceRebuild */),
        ("Can't build search index."));
  m_file.SyncWithDisk();<commit_msg>[search] Quickfix of tests - algoshops are currently invisible.<commit_after>#include "search/integration_tests/test_mwm_builder.hpp"

#include "indexer/classificator.hpp"
#include "indexer/data_header.hpp"
#include "indexer/index_builder.hpp"
#include "indexer/search_index_builder.hpp"

#include "generator/feature_builder.hpp"
#include "generator/feature_generator.hpp"
#include "generator/feature_sorter.hpp"

#include "platform/local_country_file.hpp"

#include "base/logging.hpp"

#include "defines.hpp"

TestMwmBuilder::TestMwmBuilder(platform::LocalCountryFile & file)
    : m_file(file),
      m_collector(
          make_unique<feature::FeaturesCollector>(file.GetPath(MapOptions::Map) + EXTENSION_TMP)),
      m_classificator(classif())
{
}

TestMwmBuilder::~TestMwmBuilder()
{
  if (m_collector)
    Finish();
  CHECK(!m_collector, ("Features weren't dumped on disk."));
}

void TestMwmBuilder::AddPOI(m2::PointD const & p, string const & name, string const & lang)
{
  CHECK(m_collector, ("It's not possible to add features after call to Finish()."));
  FeatureBuilder1 fb;
  fb.SetCenter(p);
  fb.SetType(m_classificator.GetTypeByPath({"railway", "station"}));
  CHECK(fb.AddName(lang, name), ("Can't set feature name:", name, "(", lang, ")"));
  (*m_collector)(fb);
}

void TestMwmBuilder::Finish()
{
  CHECK(m_collector, ("Finish() already was called."));
  m_collector.reset();
  feature::GenerateInfo info;
  info.m_targetDir = m_file.GetDirectory();
  info.m_tmpDir = m_file.GetDirectory();
  CHECK(GenerateFinalFeatures(info, m_file.GetCountryFile().GetNameWithoutExt(),
                              feature::DataHeader::country),
        ("Can't sort features."));
  CHECK(indexer::BuildIndexFromDatFile(m_file.GetPath(MapOptions::Map),
                                       m_file.GetPath(MapOptions::Map)),
        ("Can't build geometry index."));
  CHECK(indexer::BuildSearchIndexFromDatFile(m_file.GetPath(MapOptions::Map),
                                             true /* forceRebuild */),
        ("Can't build search index."));
  m_file.SyncWithDisk();
{'fraction_non_alphanumeric': 0.14608104828925017, 'fraction_numerical': 0.000970638194612958, 'mean_word_length': 4.305019305019305, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1206471', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1310, 'n_words': 222}