<commit_before>module Saxerator
  class DocumentFragment
    include Enumerable
    include DSL

    def initialize(source, config = nil, latches = [])
      @source = source
      @latches = latches
      @config = config
    end

    def each(&block)
      # Always have to start at the beginning of a File
      @source.rewind if @source.respond_to?(:rewind)

      reader = Parser::LatchedAccumulator.new(@config, @latches, block)
      @config.adapter.parse(@source, reader)
    end
  end
end<commit_msg>Return an enumerator if no block is given<commit_after>module Saxerator
  class DocumentFragment
    include Enumerable
    include DSL

    def initialize(source, config = nil, latches = [])
      @source = source
      @latches = latches
      @config = config
    end

    def each(&block)
      return to_enum unless block_given?

      # Always have to start at the beginning of a File
      @source.rewind if @source.respond_to?(:rewind)

      reader = Parser::LatchedAccumulator.new(@config, @latches, block)
      @config.adapter.parse(@source, reader)
    end
  end
end
{'fraction_non_alphanumeric': 0.08547794117647059, 'fraction_numerical': 0.0, 'mean_word_length': 2.931407942238267, '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': '1192415', 'n_tokens_mistral': 328, 'n_tokens_neox': 315, 'n_words': 98}