<commit_before># QueryReviewer
require "ostruct"
require 'erb'
require 'yaml'

module QueryReviewer
  CONFIGURATION = {}

  def self.load_configuration
    default_config = YAML::load(ERB.new(IO.read(File.join(File.dirname(__FILE__), "..", "query_reviewer_defaults.yml"))).result)

    CONFIGURATION.merge!(default_config["all"] || {})
    CONFIGURATION.merge!(default_config[Rails.env || "test"] || {})

    app_config_file = Rails.root + "config/query_reviewer.yml"

    if app_config_file.exist?
      app_config = YAML.load(ERB.new(IO.read(app_config_file)).result)
      CONFIGURATION.merge!(app_config["all"] || {})
      CONFIGURATION.merge!(app_config[Rails.env || "test"] || {})
    end

    if enabled?
      begin
        CONFIGURATION["uv"] ||= !Gem.searcher.find("uv").nil?
        if CONFIGURATION["uv"]
          require "uv"<commit_msg>Fixes searcher warnings on RubyGems 1.8.0<commit_after># QueryReviewer
require "ostruct"
require 'erb'
require 'yaml'

module QueryReviewer
  CONFIGURATION = {}

  def self.load_configuration
    default_config = YAML::load(ERB.new(IO.read(File.join(File.dirname(__FILE__), "..", "query_reviewer_defaults.yml"))).result)

    CONFIGURATION.merge!(default_config["all"] || {})
    CONFIGURATION.merge!(default_config[Rails.env || "test"] || {})

    app_config_file = Rails.root + "config/query_reviewer.yml"

    if app_config_file.exist?
      app_config = YAML.load(ERB.new(IO.read(app_config_file)).result)
      CONFIGURATION.merge!(app_config["all"] || {})
      CONFIGURATION.merge!(app_config[Rails.env || "test"] || {})
    end

    if enabled?
      begin
        CONFIGURATION["uv"] ||= if Gem::Specification.respond_to?(:find_all_by_name)
          !Gem::Specification.find_all_by_name('uv').empty?
        else # RubyGems < 1.8.0
          !Gem.searcher.find("uv").nil?
        end

        if CONFIGURATION["uv"]
          require "uv"
{'fraction_non_alphanumeric': 0.15736842105263157, 'fraction_numerical': 0.003157894736842105, 'mean_word_length': 3.764411027568922, 'pattern_counts': {'":': 0, '<': 4, '<?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': '6398716', 'n_tokens_mistral': 661, 'n_tokens_neox': 642, 'n_words': 89}