<commit_before>class ProgressBar
  module Format
    class Base
      attr_reader :molecules

      def initialize(format_string)
        @format_string = format_string
        @molecules     = parse(format_string)
      end

      def process(environment)
        processed_string = @format_string.dup

        non_bar_molecules.each do |molecule|
          processed_string.gsub!("%#{molecule.key}", environment.send(molecule.method_name).to_s)
        end

        remaining_molecules = bar_molecules.size
        placeholder_length  = remaining_molecules * 2

        processed_string.gsub! '%%', '%'
        # lenght calculated without eventual ANSI SGR codes
        processed_string_length = processed_string.gsub(/\e\[[\d;]+m/, '').length
        leftover_bar_length = environment.send(:length) - processed_string_length + placeholder_length
        leftover_bar_length = leftover_bar_length < 0 ? 0 : leftover_bar_length

        bar_molecules.each do |molecule|
          processed_string.gsub!("%#{molecule.key}", environment.send(molecule.method_name, leftover_bar_length).to_s)
        end

        processed_string
      end

    private
      def non_bar_molecules
        @non_bar_molecules ||= molecules.select { |molecule| !molecule.bar_molecule? }
      end

      def bar_molecules
        @bar_molecules     ||= molecules.select { |molecule| molecule.bar_molecule? }
      end
<commit_msg>Remove comment<commit_after>class ProgressBar
  module Format
    class Base
      attr_reader :molecules

      def initialize(format_string)
        @format_string = format_string
        @molecules     = parse(format_string)
      end

      def process(environment)
        processed_string = @format_string.dup

        non_bar_molecules.each do |molecule|
          processed_string.gsub!("%#{molecule.key}", environment.send(molecule.method_name).to_s)
        end

        remaining_molecules = bar_molecules.size
        placeholder_length  = remaining_molecules * 2

        processed_string.gsub! '%%', '%'
        processed_string_length = processed_string.gsub(/\e\[[\d;]+m/, '').length
        leftover_bar_length = environment.send(:length) - processed_string_length + placeholder_length
        leftover_bar_length = leftover_bar_length < 0 ? 0 : leftover_bar_length

        bar_molecules.each do |molecule|
          processed_string.gsub!("%#{molecule.key}", environment.send(molecule.method_name, leftover_bar_length).to_s)
        end

        processed_string
      end

    private
      def non_bar_molecules
        @non_bar_molecules ||= molecules.select { |molecule| !molecule.bar_molecule? }
      end

      def bar_molecules
        @bar_molecules     ||= molecules.select { |molecule| molecule.bar_molecule? }
      end

{'fraction_non_alphanumeric': 0.09018471568272365, 'fraction_numerical': 0.0021731256791017745, 'mean_word_length': 2.8792134831460676, 'pattern_counts': {'":': 0, '<': 5, '<?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': '110416', 'n_tokens_mistral': 893, 'n_tokens_neox': 780, 'n_words': 142}