<commit_before>module OpenXml
  module HasProperties

    class ChoiceGroupUniqueError < RuntimeError; end

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods

      def properties_tag(*args)
        @properties_tag = args.first if args.any?
        @properties_tag
      end

      def value_property(name, as: nil, klass: nil)
        attr_reader name

        properties[name] = (as || name).to_s
        class_name = klass.name unless klass.nil?
        class_name ||= "Properties::#{properties[name].split("_").map(&:capitalize).join}"

        (choice_groups[@current_group] ||= []).push(name) unless @current_group.nil?

        class_eval <<-CODE, __FILE__, __LINE__ + 1
        def #{name}=(value)
          group_index = #{@current_group.inspect}
          ensure_unique_in_group(:#{name}, group_index) unless group_index.nil?
          instance_variable_set "@#{name}", #{class_name}.new(value)
        end
        CODE
      end

      def property(name, as: nil, klass: nil)
        properties[name] = (as || name).to_s
        class_name = klass.name unless klass.nil?
        class_name ||= "Properties::#{properties[name].split("_").map(&:capitalize).join}"

        (choice_groups[@current_group] ||= []).push(name) unless @current_group.nil?

        class_eval <<-CODE, __FILE__, __LINE__ + 1
        def #{name}(*args)
          if instance_variable_get("@#{name}").nil?
            group_index = #{@current_group.inspect}
            ensure_unique_in_group(:#{name}, group_index) unless group_index.nil?
            instance_variable_set "@#{name}", #{class_name}.new(*args)
          end

          instance_variable_get "@#{name}"
        end<commit_msg>[skip] Made has_properties search adjacent properties namespace for property name (20m)<commit_after>module OpenXml
  module HasProperties

    class ChoiceGroupUniqueError < RuntimeError; end

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods

      def properties_tag(*args)
        @properties_tag = args.first if args.any?
        @properties_tag
      end

      def value_property(name, as: nil, klass: nil)
        attr_reader name

        properties[name] = (as || name).to_s
        classified_name = properties[name].split("_").map(&:capitalize).join
        class_name = klass.name unless klass.nil?
        class_name ||= (to_s.split("::")[0...-2] + ["Properties", classified_name]).join("::")

        (choice_groups[@current_group] ||= []).push(name) unless @current_group.nil?

        class_eval <<-CODE, __FILE__, __LINE__ + 1
        def #{name}=(value)
          group_index = #{@current_group.inspect}
          ensure_unique_in_group(:#{name}, group_index) unless group_index.nil?
          instance_variable_set "@#{name}", #{class_name}.new(value)
        end
        CODE
      end

      def property(name, as: nil, klass: nil)
        properties[name] = (as || name).to_s
        classified_name = properties[name].split("_").map(&:capitalize).join
        class_name = klass.name unless klass.nil?
        class_name ||= (to_s.split("::")[0...-2] + ["Properties", classified_name]).join("::")

        (choice_groups[@current_group] ||= []).push(name) unless @current_group.nil?

        class_eval <<-CODE, __FILE__, __LINE__ + 1
        def #{name}(*args)
          if instance_variable_get("@#{name}").nil?
            group_index = #{@current_group.inspect}
            ensure_unique_in_group(:#{name}, group_index) unless group_index.nil?
            instance_variable_set "@#{name}", #{class_name}.new(*args)
          end

          instance_variable_get "@#{name}"
        end
{'fraction_non_alphanumeric': 0.1377995642701525, 'fraction_numerical': 0.0027233115468409588, 'mean_word_length': 2.830031282586027, 'pattern_counts': {'":': 4, '<': 13, '<?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': '5911602', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1097, 'n_words': 225}