<commit_before>class BinaryTree
  def push(item)
    if @root
      @root.push(item)
    else
      @root = BinaryTreeNode.new(item) unless @root
    end
  end

  def size
    visitor = TotalCountVisitor.new
    accept(visitor)
    visitor.result
  end

  def accept(visitor, traversal = PreOrderTraversal.new)
    @root.accept(visitor, traversal) if @root
  end

  class BinaryTreeNode
    attr_reader :left, :right

    def initialize(data)
      @data = data
    end

    def push(item)
      if (item <=> @data) == -1
        if @left
          @left.push(item)
        else
          @left = BinaryTreeNode.new(item)
        end
      else
        if @right
          @right.push(item)
        else
          @right = BinaryTreeNode.new(item)
        end
      end
    end

    def accept(visitor, traversal)
      traversal.traverse(self, visitor)
    end
  end

  class TotalCountVisitor
    attr_reader :result
<commit_msg>add reader for data<commit_after>class BinaryTree
  def push(item)
    if @root
      @root.push(item)
    else
      @root = BinaryTreeNode.new(item) unless @root
    end
  end

  def size
    visitor = TotalCountVisitor.new
    accept(visitor)
    visitor.result
  end

  def accept(visitor, traversal = PreOrderTraversal.new)
    @root.accept(visitor, traversal) if @root
  end

  class BinaryTreeNode
    attr_reader :left, :right, :data

    def initialize(data)
      @data = data
    end

    def push(item)
      if (item <=> @data) == -1
        if @left
          @left.push(item)
        else
          @left = BinaryTreeNode.new(item)
        end
      else
        if @right
          @right.push(item)
        else
          @right = BinaryTreeNode.new(item)
        end
      end
    end

    def accept(visitor, traversal)
      traversal.traverse(self, visitor)
    end
  end

  class TotalCountVisitor
    attr_reader :result

{'fraction_non_alphanumeric': 0.08426666666666667, 'fraction_numerical': 0.0010666666666666667, 'mean_word_length': 2.0112359550561796, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3378869', 'n_tokens_mistral': 617, 'n_tokens_neox': 594, 'n_words': 152}