<commit_before>module Endive
  module Routing
    module Journey
      module TreeRouter

        class Node
          attr_accessor :data
          def initialize(options = {})
            @options = options.merge({ root: false })
            @childs = {}
          end

          def path
            @options[:path]
          end

          def unparameterized_path
            parameterized? ? path[1..-1] : path
          end

          def root?
            @options[:root]
          end

          def parent
            @options[:parent]
          end

          def get_child(path)
            @childs.fetch(path) { @parameterized_child }
          end

          def set_child(path)
            opts = { path: path, parent: self }
            if path_parameterized?(path)
              raise ArgumentError.new('Only one parameterized child per node') if @parameterized_child
              @parameterized_child = Node.new(opts)
            else
              @childs[path] = Node.new(opts)
            end

            get_child(path)
          end

          def parameterized?
            path[0] == ':'
          end

          def childs
            @childs.keys + Array.wrap(@parameterized_child.try(:path))
          end

          private
            def path_parameterized?(path)
              path[0] == ':'
            end
        end
      end
    end
  end
end<commit_msg>refactor node<commit_after>module Endive
  module Routing
    module Journey
      module TreeRouter

        class Node
          attr_accessor :data
          def initialize(options = {})
            @options = options.merge({ root: false })
            @childs = {}
          end

          def path
            @options[:path]
          end

          def unparameterized_path
            parameterized? ? path[1..-1] : path
          end

          def root?
            @options[:root]
          end

          def parent
            @options[:parent]
          end

          def get_child(path)
            @childs.fetch(path) { @parameterized_child }
          end

          def set_child(path)
            opts = { path: path, parent: self }
            node = Node.new(opts)
            if node.parameterized?
              raise ArgumentError.new('Only one parameterized child per node') if @parameterized_child
              @parameterized_child = node
            else
              @childs[path] = node
            end

            node
          end

          def parameterized?
            @parameterized ||= (path[0] == ':')
          end

          def childs
            @childs.keys + Array.wrap(@parameterized_child.try(:path))
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07894736842105263, 'fraction_numerical': 0.0025945144551519643, 'mean_word_length': 1.2548036758563075, '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': '6605327', 'n_tokens_mistral': 705, 'n_tokens_neox': 684, 'n_words': 174}