<commit_before>class Striuct; module InstanceMethods

  # @group Subscript

  # @param [Symbol, String, Fixnum] key
  def [](key)
    __subscript__(key){|autonym|__get__ autonym}
  end
  
  # @param [Symbol, String, Fixnum] key
  # @param [Object] value
  # @return [value]
  def []=(key, value)
    true_name = nil
    __subscript__(key){|autonym|true_name = autonym; __set__ autonym, value}
  rescue Validation::InvalidWritingError
    $!.set_backtrace([
      "#{$!.backtrace[-1].sub(/[^:]+\z/){''}}in `[#{key.inspect}(#{true_name})]=': #{$!.message}",
      $!.backtrace[-1]
    ])

    raise
  end

  private

  # @param [Symbol, String, Fixnum] key
  # @yield [autonym]
  # @yieldparam [Symbol] autonym
  def __subscript__(key)
    case key
    when Symbol, String
      name = keyable_for key
      if member? name
        yield autonym_for(name)
      else
        raise NameError
      end<commit_msg>refactoring<commit_after>class Striuct; module InstanceMethods

  # @group Subscript

  # @param [Symbol, String, Fixnum] key
  def [](key)
    __subscript__(key){|autonym|__get__ autonym}
  end
  
  # @param [Symbol, String, Fixnum] key
  # @param [Object] value
  # @return [value]
  def []=(key, value)
    true_name = nil
    __subscript__(key){|autonym|
      true_name = autonym
      __set__ autonym, value
    }
  rescue Validation::InvalidWritingError
    $!.set_backtrace([
      "#{$!.backtrace[-1].sub(/[^:]+\z/){''}}in `[#{key.inspect}(#{true_name})]=': #{$!.message}",
      $!.backtrace[-1]
    ])

    raise
  end

  private

  # @param [Symbol, String, Fixnum] key
  # @yield [autonym]
  # @yieldparam [Symbol] autonym
  def __subscript__(key)
    case key
    when Symbol, String
      name = keyable_for key
      if member? name
        yield autonym_for(name)
      else
        raise NameError
      end
{'fraction_non_alphanumeric': 0.14768392370572206, 'fraction_numerical': 0.0021798365122615805, 'mean_word_length': 3.017505470459519, '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': '2752638', 'n_tokens_mistral': 656, 'n_tokens_neox': 631, 'n_words': 150}