<commit_before>namespace :import do
  desc <<-DESC
    Import carriers from the old format to ActiveDocument.

    Reads the legacy carriers/defaults.yml file and creates new-style
    ActiveDocument files for each carrier. Regional variations are not yet
    included.
  DESC
  task :carriers, [:from, :to] => [:setup] do |_, args|
    include Atlas

    # Wipe out *everything* in the nodes directory; rather than simply
    # overwriting existing files, since some may have new naming conventions
    # since the previous import.
    FileUtils.rm_rf(Atlas::Node.directory)

    runner = ImportRun.new('carriers')

    path = $from_dir.join('datasets/_defaults/carriers/defaults.yml')
    data = YAML.load_file(path)

    data.each do |key, cdata|
      runner.item do
        cdata ||= Hash.new

        cdata[:key]         = key
        cdata[:infinite]    = cdata[:infinite] == 1.0
        cdata[:sustainable] = cdata[:sustainable] == 1.0

        Carrier.new(cdata)
      end
    end

    runner.finish

    Rake::Task['validate:carriers'].invoke(args.to)
  end # :carriers
end # :import<commit_msg>import:carriers deletes the correct directory<commit_after>namespace :import do
  desc <<-DESC
    Import carriers from the old format to ActiveDocument.

    Reads the legacy carriers/defaults.yml file and creates new-style
    ActiveDocument files for each carrier. Regional variations are not yet
    included.
  DESC
  task :carriers, [:from, :to] => [:setup] do |_, args|
    include Atlas

    # Wipe out *everything* in the nodes directory; rather than simply
    # overwriting existing files, since some may have new naming conventions
    # since the previous import.
    FileUtils.rm_rf(Atlas::Carrier.directory)

    runner = ImportRun.new('carriers')

    path = $from_dir.join('datasets/_defaults/carriers/defaults.yml')
    data = YAML.load_file(path)

    data.each do |key, cdata|
      runner.item do
        cdata ||= Hash.new

        cdata[:key]         = key
        cdata[:infinite]    = cdata[:infinite] == 1.0
        cdata[:sustainable] = cdata[:sustainable] == 1.0

        Carrier.new(cdata)
      end
    end

    runner.finish

    Rake::Task['validate:carriers'].invoke(args.to)
  end # :carriers
end # :import
{'fraction_non_alphanumeric': 0.10289532293986638, 'fraction_numerical': 0.0035634743875278397, 'mean_word_length': 2.9334500875656744, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6512089', 'n_tokens_mistral': 710, 'n_tokens_neox': 663, 'n_words': 199}