<commit_before>begin
  require "capybara/poltergeist/browser"
  require "capybara/poltergeist/client"
rescue LoadError
end

if defined?(Capybara::Poltergeist::Browser) && defined?(Capybara::Poltergeist::Client)
  module Capybara
    class UI
      module Poltergeist
        class Listener
          RELOAD_PATTERN = /\Acapybara-ui reload\s*\z/

          include Capybara::UI::Reload

          has_capybara_ui_session do |listener, session|
            session.driver.instance_variable_get(:@client) == listener.client
          end

          attr_reader :client, :logger, :session

          def initialize(client, logger = nil)
            @client = client
            @logger = logger
          end

          def write(data)
            reload?(data) ? capybara_ui_reload : log(data)
          end

          private

          def reload?(data)
            data =~ RELOAD_PATTERN
          end

          def log(data)
            logger.write(data) if logger
          end
        end
      end
    end<commit_msg>Remove the unused session accessor from the poltergeist listener<commit_after>begin
  require "capybara/poltergeist/browser"
  require "capybara/poltergeist/client"
rescue LoadError
end

if defined?(Capybara::Poltergeist::Browser) && defined?(Capybara::Poltergeist::Client)
  module Capybara
    class UI
      module Poltergeist
        class Listener
          RELOAD_PATTERN = /\Acapybara-ui reload\s*\z/

          include Capybara::UI::Reload

          has_capybara_ui_session do |listener, session|
            session.driver.instance_variable_get(:@client) == listener.client
          end

          attr_reader :client, :logger

          def initialize(client, logger = nil)
            @client = client
            @logger = logger
          end

          def write(data)
            reload?(data) ? capybara_ui_reload : log(data)
          end

          private

          def reload?(data)
            data =~ RELOAD_PATTERN
          end

          def log(data)
            logger.write(data) if logger
          end
        end
      end
    end
{'fraction_non_alphanumeric': 0.0785816962146622, 'fraction_numerical': 0.0, 'mean_word_length': 1.9491525423728813, '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': '235188', 'n_tokens_mistral': 616, 'n_tokens_neox': 597, 'n_words': 136}