<commit_before>class CsvRowCleaner < Struct.new :csv_row

  def transform_row
    csv_row[date_header] = DateTime.parse(csv_row[date_header]) if has_dates?
    csv_row
  end

  def clean_date?
    return true if date_header.blank?
    return false if csv_row[date_header].blank?
    (csv_row[date_header].is_a?(DateTime) || Date.parse(csv_row[date_header]))
  rescue ArgumentError
    false
  end

  def clean_booleans?
    return true if boolean_headers.blank?
    boolean_headers.all? do |header|
      csv_row[header].in? [true, false, '1', '0', 1, 0, 'true', 'false']
    end
  end

  private

  def headers
    csv_row.headers
  end

  def date_headers
    [:event_date, :date_taken, :assessment_date]<commit_msg>:csv_row => :row<commit_after>class CsvRowCleaner < Struct.new :row

  def transform_row
    row[date_header] = DateTime.parse(row[date_header]) if has_dates?
    row
  end

  def clean_date?
    return true if date_header.blank?
    return false if row[date_header].blank?
    (row[date_header].is_a?(DateTime) || Date.parse(row[date_header]))
  rescue ArgumentError
    false
  end

  def clean_booleans?
    return true if boolean_headers.blank?
    boolean_headers.all? do |header|
      row[header].in? [true, false, '1', '0', 1, 0, 'true', 'false']
    end
  end

  private

  def headers
    row.headers
  end

  def date_headers
    [:event_date, :date_taken, :assessment_date]
{'fraction_non_alphanumeric': 0.10691375623663578, 'fraction_numerical': 0.005702066999287242, 'mean_word_length': 3.6956521739130435, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5005859', 'n_tokens_mistral': 508, 'n_tokens_neox': 486, 'n_words': 116}