<commit_before>module ReplacerBot
  class Replacer
    attr_reader :results, :config

    def initialize
      @config = Config.instance.config
      @search_term = @config.search_term
      @client = TwitterClient.client
    end

    def search #count = 20
      @results ||= begin
        results = ReplacerBot.filter @client.search(ReplacerBot.encode(@search_term), result_type: 'recent').take(@config.search_count), @config.ignore_spaces
      end
    end

    def tweets
      search.map { |r| ReplacerBot.truncate ReplacerBot.replace r.text }
    end

    def tweet
      tweets.each do |tweet|
        puts "Tweeting: #{tweet}"
        @client.update tweet
        puts "Sleeping #{@config.interval} seconds"
        sleep @config.interval
      end

      save
    end

    def save
      if search.first

        File.open @config.save_file, 'w' do |file|
          Marshal.dump search.first.id, file
        end
      end
    end
  end
end<commit_msg>Don't sleep on the last go<commit_after>module ReplacerBot
  class Replacer
    attr_reader :results, :config

    def initialize
      @config = Config.instance.config
      @search_term = @config.search_term
      @client = TwitterClient.client
    end

    def search #count = 20
      @results ||= begin
        results = ReplacerBot.filter @client.search(ReplacerBot.encode(@search_term), result_type: 'recent').take(@config.search_count), @config.ignore_spaces
      end
    end

    def tweets
      search.map { |r| ReplacerBot.truncate ReplacerBot.replace r.text }
    end

    def tweet
      tweets.each_with_index do |tweet, index|
        puts "Tweeting: #{tweet}"
        @client.update tweet
        unless index == tweets.count - 1
          puts "Sleeping #{@config.interval} seconds"
          sleep @config.interval
        end
      end

      save
    end

    def save
      if search.first

        File.open @config.save_file, 'w' do |file|
          Marshal.dump search.first.id, file
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08855721393034825, 'fraction_numerical': 0.0024875621890547263, 'mean_word_length': 2.2435483870967743, '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': '3281665', 'n_tokens_mistral': 637, 'n_tokens_neox': 607, 'n_words': 158}