<commit_before>require 'schlepp/sink/data_object'

module Schlepp
  module Sink
    class Loader
      def initialize(writer, opts = {})
        @writer = writer

        @file = DataObject.new(writer)
      end

      def name
        @writer.name
      end

      def path
        @writer.path
      end

      def write(rows)
        rows.each do |row|
          @file.write(row)
        end
      end

      def written
        @file.length
      end

      def finalize<commit_msg>Loader wants to be able to take either singular or collections of things.<commit_after>require 'schlepp/sink/data_object'

module Schlepp
  module Sink
    class Loader
      def initialize(writer, opts = {})
        @writer = writer

        @file = DataObject.new(writer)
      end

      def name
        @writer.name
      end

      def path
        @writer.path
      end

      def write(rows)
        Array(rows).each do |row|
          @file.write(row)
        end
      end

      def written
        @file.length
      end

      def finalize
{'fraction_non_alphanumeric': 0.07025986525505294, 'fraction_numerical': 0.0, 'mean_word_length': 1.5870646766169154, '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': '784231', 'n_tokens_mistral': 313, 'n_tokens_neox': 302, 'n_words': 87}