<commit_before>require_relative '../../util/not_supported_exception'

class MapValuesToRuby

  def map(ast)
    if ast.is_a?(Array)
      operator = ast[0]
      if respond_to?(operator)
        send(operator,*ast[1..-1])
      else
        raise NotSupportedException.new("#{operator} in #{ast.inspect} not supported")
      end
    else
      raise NotSupportedException.new("#{ast} not supported")
    end
  end
  
  def blank
    "nil"
  end
    
  def number(text)
    case text
    when /\./
      text.to_f.to_s
    when /e/i
      text.to_f.to_s
    else
      text.to_i.to_s
    end
  end
  
  def string(text)
    text.inspect
  end
  
  ERRORS = {
    "#NAME?" => ":name",
    "#VALUE!" => ":value",
    "#DIV/0!" => ":div0"
  }
  
  REVERSE_ERRORS = ERRORS.invert
  
  def error(text)
    ERRORS[text] || (raise NotSupportedException.new("#{text} error not recognised"))
  end
  
  def boolean_true
    "true"
  end
  
  def boolean_false
    "false"
  end
  
end
<commit_msg>Added some more error types to map_values_to_ruby.rb<commit_after>require_relative '../../util/not_supported_exception'

class MapValuesToRuby

  def map(ast)
    if ast.is_a?(Array)
      operator = ast[0]
      if respond_to?(operator)
        send(operator,*ast[1..-1])
      else
        raise NotSupportedException.new("#{operator} in #{ast.inspect} not supported")
      end
    else
      raise NotSupportedException.new("#{ast} not supported")
    end
  end
  
  def blank
    "nil"
  end
    
  def number(text)
    case text
    when /\./
      text.to_f.to_s
    when /e/i
      text.to_f.to_s
    else
      text.to_i.to_s
    end
  end
  
  def string(text)
    text.inspect
  end
  
  ERRORS = {
    "#NAME?" => ":name",
    "#VALUE!" => ":value",
    "#DIV/0!" => ":div0",
    "#REF!" => ":ref",
    "#N/A" => ":na"
  }
  
  REVERSE_ERRORS = ERRORS.invert
  
  def error(text)
    ERRORS[text] || (raise NotSupportedException.new("#{text.inspect} error not recognised"))
  end
  
  def boolean_true
    "true"
  end
  
  def boolean_false
    "false"
  end
  
end

{'fraction_non_alphanumeric': 0.13352685050798258, 'fraction_numerical': 0.004837929366231253, 'mean_word_length': 2.221183800623053, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 11, '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': '511009', 'n_tokens_mistral': 759, 'n_tokens_neox': 761, 'n_words': 162}