<commit_before>module ISO3166
  ##
  # Handles building the in memory store of countries data
  class Data
    def initialize(alpha2)
      @alpha2 = alpha2.to_s.upcase
    end

    def call
      CACHE[@alpha2]
    end

    def self.codes
      @@codes ||= Data.load_yaml(['data', 'countries.yaml']).freeze
    end

    private

    def self.datafile_path(file_array)
      File.join([File.dirname(__FILE__), '..'] + file_array)
    end

    def self.load_yaml(file_array)
      YAML.load_file(datafile_path(file_array))
    end

    CACHE = Marshal.load(File.binread(Data.datafile_path(%w(cache countries))))
  end
end
<commit_msg>Load on first call<commit_after>module ISO3166
  ##
  # Handles building the in memory store of countries data
  class Data
    @@cache = nil
    def initialize(alpha2)
      @alpha2 = alpha2.to_s.upcase
      Data.load_cache unless @@cache
    end

    def call
       @@cache[@alpha2]
    end

    def self.codes
      @@codes ||= Data.load_yaml(['data', 'countries.yaml']).freeze
    end

    private

    def self.datafile_path(file_array)
      File.join([File.dirname(__FILE__), '..'] + file_array)
    end

    def self.load_yaml(file_array)
      YAML.load_file(datafile_path(file_array))
    end

    def self.load_cache
      @@cache ||= Marshal.load(File.binread(datafile_path %w(cache countries )))
    end
  end
end

{'fraction_non_alphanumeric': 0.11160058737151249, 'fraction_numerical': 0.011747430249632892, 'mean_word_length': 2.861189801699717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4293893', 'n_tokens_mistral': 479, 'n_tokens_neox': 452, 'n_words': 98}