<commit_before>module Kartograph
  module DSL
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def kartograph(&block)
        @kartograph_map ||= Map.new

        if block_given?
          block.arity > 0 ? block.call(@kartograph_map) : @kartograph_map.instance_eval(&block)
        end

        @kartograph_map
      end

      def hash_for(scope, object)
        drawn_object = Artist.new(object, @kartograph_map).draw(scope)
        prepend_root_key(scope, :singular, drawn_object)
      end

      def hash_collection_for(scope, objects)
        drawn_objects = objects.map do |object|
          Artist.new(object, @kartograph_map).draw(scope)
        end

        prepend_root_key(scope, :plural, drawn_objects)<commit_msg>Add simple comments to hash methods<commit_after>module Kartograph
  module DSL
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def kartograph(&block)
        @kartograph_map ||= Map.new

        if block_given?
          block.arity > 0 ? block.call(@kartograph_map) : @kartograph_map.instance_eval(&block)
        end

        @kartograph_map
      end

      # Returns a hash representation of the object based on the mapping
      #
      # @param scope [Symbol] the scope of the mapping
      # @param object the object to be mapped
      # @return [Hash, Array]
      def hash_for(scope, object)
        drawn_object = Artist.new(object, @kartograph_map).draw(scope)
        prepend_root_key(scope, :singular, drawn_object)
      end

      # Returns a hash representation of the collection of objects based on the mapping
      #
      # @param scope [Symbol] the scope of the mapping
      # @params objects [Array] the array of objects to be mapped
      # @return [Hash, Array]
      def hash_collection_for(scope, objects)
        drawn_objects = objects.map do |object|
          Artist.new(object, @kartograph_map).draw(scope)
        end

        prepend_root_key(scope, :plural, drawn_objects)
{'fraction_non_alphanumeric': 0.07960687960687961, 'fraction_numerical': 0.0009828009828009828, 'mean_word_length': 2.629233511586453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5591821', 'n_tokens_mistral': 613, 'n_tokens_neox': 591, 'n_words': 161}