<commit_before>module JSON
  module SchemaBuilder
    module DSL
      extend ActiveSupport::Concern
      mattr_accessor :types

      def entity(type, name, opts = { }, &block)
        opts[:parent] ||= self if is_a?(Entity)
        DSL.types[type].new name, opts, &block
      end

      module ClassMethods
        def register(type)
          self.registered_type = type
          DSL.types ||= { }
          DSL.types[type] = self

          DSL.module_eval do
            define_method type do |*args, &block|
              opts = args.extract_options!
              name = args.first
              entity type, name, opts, &block
            end
          end
        end
      end
    end
  end
end<commit_msg>Allow untyped entity literals<commit_after>module JSON
  module SchemaBuilder
    module DSL
      extend ActiveSupport::Concern
      mattr_accessor :types

      def entity(*args, &block)
        opts = args.extract_options!
        klass, name = klass_and_name_from args
        opts[:parent] ||= self if is_a?(Entity)
        klass.new name, opts, &block
      end

      protected

      def klass_and_name_from(args)
        type, name = args
        if DSL.types[type]
          [DSL.types[type], name]
        else
          [Entity, type]
        end
      end

      module ClassMethods
        def register(type)
          self.registered_type = type
          DSL.types ||= { }
          DSL.types[type] = self

          DSL.module_eval do
            define_method type do |*args, &block|
              opts = args.extract_options!
              name = args.first
              entity type, name, opts, &block
            end
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07827102803738317, 'fraction_numerical': 0.0, 'mean_word_length': 1.5993930197268589, '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': '5300038', 'n_tokens_mistral': 495, 'n_tokens_neox': 485, 'n_words': 133}