<commit_before>#pragma once

#include "geometry/latlon.hpp"
#include "geometry/mercator.hpp"
#include "geometry/rect2d.hpp"

#include "base/string_utils.hpp"

#include "std/string.hpp"
#include "std/vector.hpp"

class TownsDumper
{
public:
  TownsDumper();

  template <typename TElement>
  void CheckElement(TElement const & em)
  {
    if (em.type != TElement::EntityType::Node)
      return;
    uint64_t population = 1;
    bool town = false;
    bool capital = false;
    for (auto const & tag : em.Tags())
    {
      string key(tag.key), value(tag.value);
      if (key == "population")
      {
        try
        {
          strings::to_uint64(value, population);
        }
        catch (std::invalid_argument const &)
        {
          continue;
        }
      }
      else if (key == "capital" && value == "yes")
      {
        capital = true;
      }
      else if (key == "place" && (value == "city" || value == "town"))
      {
        town = true;
      }
    }
    if (town || capital)
      m_records.emplace_back(em.lat, em.lon, em.id, capital, population);
  }

  void Dump(string const & filePath);

private:
  void FilterTowns();

  struct Town
  {
    ms::LatLon point;<commit_msg>Review fixes.<commit_after>#pragma once

#include "geometry/latlon.hpp"
#include "geometry/mercator.hpp"
#include "geometry/rect2d.hpp"

#include "base/string_utils.hpp"

#include "std/string.hpp"
#include "std/vector.hpp"

class TownsDumper
{
public:
  TownsDumper();

  template <typename TElement>
  void CheckElement(TElement const & em)
  {
    if (em.type != TElement::EntityType::Node)
      return;
    uint64_t population = 1;
    bool town = false;
    bool capital = false;
    for (auto const & tag : em.Tags())
    {
      string key(tag.key), value(tag.value);
      if (key == "population")
      {
        if (!strings::to_uint64(value, population))
          continue;
      }
      else if (key == "capital" && value == "yes")
      {
        capital = true;
      }
      else if (key == "place" && (value == "city" || value == "town"))
      {
        town = true;
      }
    }
    if (town || capital)
      m_records.emplace_back(em.lat, em.lon, em.id, capital, population);
  }

  void Dump(string const & filePath);

private:
  void FilterTowns();

  struct Town
  {
    ms::LatLon point;
{'fraction_non_alphanumeric': 0.14390348987505386, 'fraction_numerical': 0.005170185264971995, 'mean_word_length': 2.4197349042709866, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5907499', 'n_tokens_mistral': 796, 'n_tokens_neox': 775, 'n_words': 183}