<commit_before>require File.join(File.dirname(__FILE__), "../../script/surveyor/survey_parser")
require 'active_record/fixtures'

namespace :surveyor do

  desc "generate and load survey fixtures from survey file (shortcut for rake surveyor:generate and rake surveyor:load)"
  task :bootstrap => [:generate, :load]
  
  desc "generate survey fixtures from survey file"
  task :generate => :environment do
    raise "usage: file name required e.g. 'FILE=surveys/kitchen_sink_survey.rb'" if ENV["FILE"].blank?
    SurveyParser.parse(File.join(RAILS_ROOT, ENV["FILE"]))
  end

  desc "load survey fixtures"
  task :load => :environment do
    ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)

    fixture_dir = File.join(RAILS_ROOT, "surveys", "fixtures")
    fixtures = Dir.glob("#{fixture_dir}/*.yml")
    raise "No fixtures found." if fixtures.empty?
    
    fixtures.each do |file_name|
      puts "Loading #{file_name}..."
      Fixtures.create_fixtures(fixture_dir, File.basename(file_name, '.*'))
    end
  end

end
<commit_msg>minor renaming of surveyor tasks<commit_after>require File.join(File.dirname(__FILE__), "../../script/surveyor/survey_parser")
require 'active_record/fixtures'

namespace :surveyor do

  desc "generate and load survey fixtures from survey file (shortcut for rake surveyor:generate and rake surveyor:load)"
  task :import => [:generate_fixtures, :load_fixtures]
  
  desc "generate survey fixtures from survey file"
  task :generate_fixtures => :environment do
    raise "usage: file name required e.g. 'FILE=surveys/kitchen_sink_survey.rb'" if ENV["FILE"].blank?
    SurveyParser.parse(File.join(RAILS_ROOT, ENV["FILE"]))
  end

  desc "load survey fixtures"
  task :load_fixtures => :environment do
    ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)

    fixture_dir = File.join(RAILS_ROOT, "surveys", "fixtures")
    fixtures = Dir.glob("#{fixture_dir}/*.yml")
    raise "No fixtures found." if fixtures.empty?
    
    fixtures.each do |file_name|
      puts "Loading #{file_name}..."
      Fixtures.create_fixtures(fixture_dir, File.basename(file_name, '.*'))
    end
  end

end

{'fraction_non_alphanumeric': 0.12453183520599251, 'fraction_numerical': 0.0, 'mean_word_length': 4.410126582278481, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4306565', 'n_tokens_mistral': 714, 'n_tokens_neox': 700, 'n_words': 170}