<commit_before>module JSONLogic
  class RuleSet
    def initialize(logic, data)
      @logic = logic
      @data = data || {}
    end

    def evaluate(logic = @logic)
      return logic unless logic.is_a?(Hash)
      operator, values = logic.first # unwrap 1-key hash
      values = [values] unless values.is_a? Array
      evaluated_values = values.map { |value| evaluate(value) }
      Operation.perform(operator, evaluated_values, @data)
    end
  end
end
<commit_msg>Fix bug with wrapped arrays<commit_after>module JSONLogic
  class RuleSet
    def initialize(logic, data)
      @logic = logic
      @data = data || {}
    end

    def evaluate(logic = @logic)
      return logic unless logic.is_a?(Hash)
      operator, values = logic.first # unwrap hash with single key
      values = [values] unless values.is_a? Array
      evaluated_values = values.map { |value| evaluate(value) }
      evaluated_values.flatten!(1) if evaluated_values.size == 1 # [['A']] => ['A']
      Operation.perform(operator, evaluated_values, @data)
    end
  end
end

{'fraction_non_alphanumeric': 0.10551330798479087, 'fraction_numerical': 0.0028517110266159697, 'mean_word_length': 3.0038022813688214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5186248', 'n_tokens_mistral': 324, 'n_tokens_neox': 316, 'n_words': 92}