<commit_before>module Pairwise
  class PairCollection < Array

    def initialize(parameter_i, input_lists, p_index)
      pairs = generate_pairs_between(parameter_i, input_lists, p_index)
      super(pairs)
    end

    def remove_pairs_covered_by!(extended_input_list)
      self.reject!{|pair| pair.covered_by?(extended_input_list)}
    end

    def input_combination_that_covers_most_pairs(input_combination, input_values_for_growth)
      selected_input_combination = nil
      input_values_for_growth.reduce(0) do |max_covered_count, value|
        input_combination_candidate = input_combination + [value]
        covered_count = pairs_covered_count(input_combination_candidate)
        if covered_count >= max_covered_count
          selected_input_combination = input_combination_candidate
          covered_count
        else
          max_covered_count
        end
      end
      selected_input_combination
    end

    def to_a
      self.map{|list| list.to_a}
    end

    private
    def generate_pairs_between(parameter_i, input_lists, p_index)
      pairs = []
      parameter_i.each do |p|
        input_lists.each_with_index do |input_list, q_index|
          input_list.each do |q|
            pairs << TestPair.new(p_index, q_index, p, q)
          end
        end
      end
      pairs
    end

    def pairs_covered_count(input_combination)
      self.reduce(0) do |covered_count, pair|
        covered_count += 1 if pair.covered_by?(input_combination)
        covered_count
      end
    end
  end
end<commit_msg>Refactor: Better intention revealing names<commit_after>module Pairwise
  class PairCollection < Array

    def initialize(input_parameter_values, input_value_lists, input_parameter_index)
      pairs = generate_pairs_between(input_parameter_values, input_value_lists, input_parameter_index)
      super(pairs)
    end

    def remove_pairs_covered_by!(extended_input_list)
      self.reject!{|pair| pair.covered_by?(extended_input_list)}
    end

    def input_combination_that_covers_most_pairs(input_combination, input_values_for_growth)
      selected_input_combination = nil
      input_values_for_growth.reduce(0) do |max_covered_count, value|
        input_combination_candidate = input_combination + [value]
        covered_count = pairs_covered_count(input_combination_candidate)
        if covered_count >= max_covered_count
          selected_input_combination = input_combination_candidate
          covered_count
        else
          max_covered_count
        end
      end
      selected_input_combination
    end

    def to_a
      self.map{|list| list.to_a}
    end

    private
    def generate_pairs_between(input_parameter_values, input_value_lists, input_parameter_index)
      pairs = []
      input_parameter_values.each do |input_value_a|
        input_value_lists.each_with_index do |input_list, input_value_b_index|
          input_list.each do |input_value_b|
            pairs << TestPair.new(input_parameter_index, input_value_b_index, input_value_a, input_value_b)
          end
        end
      end
      pairs
    end

    def pairs_covered_count(input_combination)
      self.reduce(0) do |covered_count, pair|
        covered_count += 1 if pair.covered_by?(input_combination)
        covered_count
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.05668384358896635, 'fraction_numerical': 0.0018187329493785996, 'mean_word_length': 3.1614123581336697, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6415126', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1006, 'n_words': 187}