<commit_before>require 'random-word'

module DbSubsetter
  class Scrambler
    def scramble(table, row)
      scramble_method = "scramble_#{table.downcase}"
      if self.respond_to? scramble_method
        self.send(scramble_method, row)
      else
        row
      end
    end

    def initialize
      @column_index_cache = {}
    end

    protected
    def scramble_column(table, column, row_data, value)
      row_data[column_index(table, column)] = value
    end

    private
    def column_index(table, column)
      @column_index_cache["#{table}##{column}"] ||= ActiveRecord::Base.connection.columns(table).map{|table| table.name}.index(column.to_s)
    end
  end
end<commit_msg>merging master<commit_after>require 'random-word'

module DbSubsetter
  class Scrambler
    def scramble(table, row)
      scramble_method = "scramble_#{table.downcase}"
      if self.respond_to? scramble_method
        self.send(scramble_method, row)
      else
        row
      end
    end

    def initialize
      @column_index_cache = {}
    end

    protected
    def scramble_column(table, column, row_data, value)
      row_data[column_index(table, column)] = value
    end

    private
    def column_index(table, column)
      @column_index_cache["#{table}##{column}"] ||= ActiveRecord::Base.connection.columns(table).map{|c| c.name}.index(column.to_s)
    end
  end
end
{'fraction_non_alphanumeric': 0.10372534696859022, 'fraction_numerical': 0.0, 'mean_word_length': 3.1515151515151514, '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': '6692857', 'n_tokens_mistral': 459, 'n_tokens_neox': 442, 'n_words': 88}