<commit_before># -*- encoding: utf-8 -*-

require 'tty/vector'
require 'forwardable'

module TTY
  class Table

    # Convert an Array row into Header
    #
    # @return [TTY::Table::Header]
    #
    # @api private
    def to_header(row)
      Header.new(row)
    end

    # A set of header elements that correspond with values in each row
    class Header < Vector
      include Equatable
      extend Forwardable

      def_delegators :@attributes, :join, :map, :map!

      # The header attributes
      #
      # @return [Array]
      #
      # @api private
      attr_reader :attributes

      # Initialize a Header
      #
      # @return [undefined]
      #
      # @api public
      def initialize(attributes=[])
        @attributes    = attributes.map { |attr| to_field(attr) }
        @attribute_for = Hash[@attributes.each_with_index.map.to_a]
      end

      # Instantiates a new field
      #
      # @api public
      def to_field(options=nil)
        Field.new(options)
      end

      # Filter header names including styling background,
      # text color and capitalization
      #
      #
      def filter
      end

      # Lookup a column in the header given a name
      #
      # @api public
      def [](attribute)
        case attribute
        when Integer
          @attributes[attribute].value
        else
          @attribute_for.fetch(to_field(attribute)) do |header_name|
            raise UnknownAttributeError, "the header '#{header_name.value}' is unknown"
          end
        end
      end
      alias :call :[]

      # Set value at index
      #
      # @example
      #   header[attribute] = value
      #
      # @api public
      def []=(attribute, value)
        self.attributes[attribute] = to_field(value)
      end

      # Size of the header
      #
      # @api public
      def size
        to_ary.size
      end
      alias :length :size

      # Convert the Header into an Array
      #
      # @api public
      def to_ary
        attributes.map { |attr| attr.value if attr.value }
      end
<commit_msg>Change the object check.<commit_after># -*- encoding: utf-8 -*-

require 'tty/vector'
require 'forwardable'

module TTY
  class Table

    # Convert an Array row into Header
    #
    # @return [TTY::Table::Header]
    #
    # @api private
    def to_header(row)
      Header.new(row)
    end

    # A set of header elements that correspond with values in each row
    class Header < Vector
      include Equatable
      extend Forwardable

      def_delegators :@attributes, :join, :map, :map!

      # The header attributes
      #
      # @return [Array]
      #
      # @api private
      attr_reader :attributes

      # Initialize a Header
      #
      # @return [undefined]
      #
      # @api public
      def initialize(attributes=[])
        @attributes    = attributes.map { |attr| to_field(attr) }
        @attribute_for = Hash[@attributes.each_with_index.map.to_a]
      end

      # Instantiates a new field
      #
      # @api public
      def to_field(options=nil)
        Field.new(options)
      end

      # Filter header names including styling background,
      # text color and capitalization
      #
      #
      def filter
      end

      # Lookup a column in the header given a name
      #
      # @api public
      def [](attribute)
        case attribute
        when Integer
          @attributes[attribute].value
        else
          @attribute_for.fetch(to_field(attribute)) do |header_name|
            raise UnknownAttributeError, "the header '#{header_name.value}' is unknown"
          end
        end
      end
      alias :call :[]

      # Set value at index
      #
      # @example
      #   header[attribute] = value
      #
      # @api public
      def []=(attribute, value)
        self.attributes[attribute] = to_field(value)
      end

      # Size of the header
      #
      # @api public
      def size
        to_ary.size
      end
      alias :length :size

      # Convert the Header into an Array
      #
      # @api public
      def to_ary
        attributes.map { |attr| attr.value if attr }
      end

{'fraction_non_alphanumeric': 0.08533333333333333, 'fraction_numerical': 0.00048484848484848484, 'mean_word_length': 1.7765814266487214, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2847535', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1153, 'n_words': 353}