<commit_before>require 'forwardable'
require 'set'
require 'map'

module Yacl
  # Properties is a wrapper around keys and values that are part of a
  # Configuration. This is just the keys and the values, it does not tie it to
  # where the data comes from.
  #
  # The properties interface is a limited subset of the Hash interface.
  #
  # In a Properties, all keys are strings.
  #
  class Properties
    extend Forwardable

    # Currently wrapping a hash.
    def_delegators :@map, :fetch, :store, :delete, :clear, :[], :[]=, :has_key?, :each, :length, :keys, :method_missing

    def initialize( initial = {} )
      @map = Map.new
      expanded_keys( initial ) do |k,v|
        k << v
        @map.set( *k )
      end
    end

    # Return a new Properties that is a subset of the properties with the first
    # prefix removed.
    def scoped_by( *scope )
      scope = scope.length == 1 ? scope.first : scope
      Properties.new( @map.get( expand_key( scope ) ) )
    end

    def scopes
      scope_names.to_a.sort
    end

    def has_scope?( scope )
      scope_names.include?( scope )<commit_msg>delegate set and get to map also<commit_after>require 'forwardable'
require 'set'
require 'map'

module Yacl
  # Properties is a wrapper around keys and values that are part of a
  # Configuration. This is just the keys and the values, it does not tie it to
  # where the data comes from.
  #
  # The properties interface is a limited subset of the Hash interface.
  #
  # In a Properties, all keys are strings.
  #
  class Properties
    extend Forwardable

    # Currently wrapping a map
    def_delegators :@map, :set, :get, :fetch, :store, :delete, :clear, :[], :[]=, :has_key?, :each, :length, :keys, :method_missing

    def initialize( initial = {} )
      @map = Map.new
      expanded_keys( initial ) do |k,v|
        k << v
        @map.set( *k )
      end
    end

    # Return a new Properties that is a subset of the properties with the first
    # prefix removed.
    def scoped_by( *scope )
      scope = scope.length == 1 ? scope.first : scope
      Properties.new( @map.get( expand_key( scope ) ) )
    end

    def scopes
      scope_names.to_a.sort
    end

    def has_scope?( scope )
      scope_names.include?( scope )
{'fraction_non_alphanumeric': 0.09551310528653932, 'fraction_numerical': 0.000888494002665482, 'mean_word_length': 2.644012944983819, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3673330', 'n_tokens_mistral': 694, 'n_tokens_neox': 687, 'n_words': 270}