<commit_before>module Alf
  module Types
    #
    # An attribute list is an ordered collection of attribute names (see AttrName).
    #
    # Example:
    #
    #     list = AttrList[:name, :city]
    #
    class AttrList

      # @return [Array<AttrName>] the list of attribute names
      attr_accessor :attributes

      # Creates an AttrList instance.
      #
      # @param [Array<AttrName>] the list of attribute names
      def initialize(attributes)
        @attributes = attributes
      end

      class << self

        # Coerces `arg` to an AttrList.
        #
        # Recognizes coercions are:
        # - AttrList -> self
        # - Ordering -> the underlying list of attributes
        # - Array    -> through AttrName coercion of its elements
        #
        # @param [Object] arg the value to coerce to an AttrList
        # @return [AttrList] an attribute list if coercion succeeds
        # @raise [ArgumentError] if the coercion fails
        def coerce(arg)
          return arg.to_attr_list if arg.respond_to?(:to_attr_list)
          case arg
          when Array
            AttrList.new(arg.collect{|s| Tools.coerce(s, AttrName)})
          else
            raise ArgumentError, "Unable to coerce #{arg} to a projection key"
          end
        end

        # Coerces a list of names to an AttrList.
        #
        # @param [Array] args a list of names (Symbol or String)
        # @return [AttrList] an attribute list
        def [](*args)
          coerce(args)
        end

        # Builds an AttrList from commandline arguments.
        #
        # This method relies on `coerce` and therefore shares its spec.
        #
        # @param [Array] argv an array of commandline arguments
        # @param [Hash] opts convertion options (unused)
        # @return [AttrList] an attribute list if coercion succeeds
        # @raise [ArgumentError] if the coercion fails
        def from_argv(argv, opts = {})<commit_msg>Enhance an error message in AttrList<commit_after>module Alf
  module Types
    #
    # An attribute list is an ordered collection of attribute names (see AttrName).
    #
    # Example:
    #
    #     list = AttrList[:name, :city]
    #
    class AttrList

      # @return [Array<AttrName>] the list of attribute names
      attr_accessor :attributes

      # Creates an AttrList instance.
      #
      # @param [Array<AttrName>] the list of attribute names
      def initialize(attributes)
        @attributes = attributes
      end

      class << self

        # Coerces `arg` to an AttrList.
        #
        # Recognizes coercions are:
        # - AttrList -> self
        # - Ordering -> the underlying list of attributes
        # - Array    -> through AttrName coercion of its elements
        #
        # @param [Object] arg the value to coerce to an AttrList
        # @return [AttrList] an attribute list if coercion succeeds
        # @raise [ArgumentError] if the coercion fails
        def coerce(arg)
          return arg.to_attr_list if arg.respond_to?(:to_attr_list)
          case arg
          when Array
            AttrList.new(arg.collect{|s| Tools.coerce(s, AttrName)})
          else
            raise ArgumentError, "Unable to coerce `#{arg.inspect}` to a projection key"
          end
        end

        # Coerces a list of names to an AttrList.
        #
        # @param [Array] args a list of names (Symbol or String)
        # @return [AttrList] an attribute list
        def [](*args)
          coerce(args)
        end

        # Builds an AttrList from commandline arguments.
        #
        # This method relies on `coerce` and therefore shares its spec.
        #
        # @param [Array] argv an array of commandline arguments
        # @param [Hash] opts convertion options (unused)
        # @return [AttrList] an attribute list if coercion succeeds
        # @raise [ArgumentError] if the coercion fails
        def from_argv(argv, opts = {})
{'fraction_non_alphanumeric': 0.07782002534854246, 'fraction_numerical': 0.0, 'mean_word_length': 1.97811320754717, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4196728', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1071, 'n_words': 397}