<commit_before>#!/usr/bin/env ruby
# encoding: UTF-8

module CommonCore
  class Loader
    class << self
      def math_standards
        load_standards_from_path File.expand_path('../../../data/Mathematics/StandardItems/Grade*/*.xml',  __FILE__)
      end
      
      def math_domains
        load_domains_from_path File.expand_path('../../../data/Mathematics/Standards/*.xml',  __FILE__)
      end
      
      def ela_standards
        load_standards_from_path File.expand_path('../../../data/ELA_08302010/StandardItems/Grade*/*.xml',  __FILE__)
      end
      
    private
      
      def load_standards_from_path(path)
        (Dir.glob(path).map do |filename|
          CommonCore::Standard.new(Nokogiri::XML(Pathname.new filename)) rescue nil
        end).compact
      end
      
      def load_domains_from_path(path)
        (Dir.glob(path).map do |filename|
          CommonCore::Domain.new(Nokogiri::XML(Pathname.new filename)) rescue nil
        end).compact
      end
    end
  end
end<commit_msg>consolidate<commit_after>#!/usr/bin/env ruby
# encoding: UTF-8

module CommonCore
  class Loader
    class << self
      def math_standards
        load_elements_from_path(CommonCore::Standard, File.expand_path('../../../data/Mathematics/StandardItems/Grade*/*.xml',  __FILE__))
      end
      
      def math_domains
        load_elements_from_path(CommonCore::Domain, File.expand_path('../../../data/Mathematics/Standards/*.xml',  __FILE__))
      end
      
      def ela_standards
        load_elements_from_path(CommonCore::Standard, File.expand_path('../../../data/ELA_08302010/StandardItems/Grade*/*.xml',  __FILE__))
      end
      
    private
      
      def load_elements_from_path(klass, path)
        (Dir.glob(path).map do |filename|
          klass.new(Nokogiri::XML(Pathname.new filename)) rescue nil
        end).compact
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12274176408076515, 'fraction_numerical': 0.009564293304994687, 'mean_word_length': 2.429872495446266, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6855070', 'n_tokens_mistral': 618, 'n_tokens_neox': 592, 'n_words': 97}