<commit_before># coding: utf-8

require 'csv'
require 'stringio'

module Dech
  class CSV < StringIO
    DEFAULT_ENCODING = Encoding::Windows_31J

    def initialize(array, args={})
      @array = array
      @option = {}
      @option[:headers]  = args[:headers] != false
      @option[:encoding] = args[:encoding] || DEFAULT_ENCODING
      super(csv_string)
    end

    def headers
      @option[:headers] ? @array.first : nil
    end

    def save_as(path)
      FileUtils.mkdir_p(File.dirname(path))
      File.open(path, [:w, @option[:encoding].name].join(":")){|file| file << csv_string }
    end<commit_msg>Add default blank constants to Dech::CSV. #7<commit_after># coding: utf-8

require 'csv'
require 'stringio'

module Dech
  class CSV < StringIO
    DEFAULT_ENCODING = Encoding::Windows_31J

    HEADER_MAPPINGS  = {}
    REQUIRED_HEADERS = []
    STATIC_COLUMNS   = {}

    def initialize(array, args={})
      @array = array
      @option = {}
      @option[:headers]  = args[:headers] != false
      @option[:encoding] = args[:encoding] || DEFAULT_ENCODING
      super(csv_string)
    end

    def headers
      @option[:headers] ? @array.first : nil
    end

    def save_as(path)
      FileUtils.mkdir_p(File.dirname(path))
      File.open(path, [:w, @option[:encoding].name].join(":")){|file| file << csv_string }
    end
{'fraction_non_alphanumeric': 0.14253731343283582, 'fraction_numerical': 0.0052238805970149255, 'mean_word_length': 3.126153846153846, 'pattern_counts': {'":': 2, '<': 9, '<?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': '604119', 'n_tokens_mistral': 463, 'n_tokens_neox': 438, 'n_words': 94}