<commit_before>module EAlert
  class TwitterFilter
    
    
    ##
    # By Keywords
    #
    # @param  [String, String, Array]
    # @api    Private
    #
    def self.by_keywords(config, event_name)
      auth      = [config['twitter']['login'], config['twitter']['pass']]
      file      = File.expand_path(::EAlert::USER_CONFIG) + '/tweets' 
      filters   = config['keywords'].split(',').collect! { |w| w.strip }.join(',') # TODO: Sanitize

      `mkdir -p #{file}` unless File.exists?(file)
  
      EventMachine.run do
        http = ::EventMachine::HttpRequest.new("http://stream.twitter.com/1/statuses/filter.json").get(
          :head   => {'authorization' => auth},
          :query  => {:track          => filters}
        )
        http.stream do |chunk| 
          # File.open(File.join(file,"#{Date.today.to_s}_#{event_name}.json"), 'a+') { |f| f.write(chunk) }
          a = ::EAlert::Parse.json(chunk)
          STDOUT.puts(a)
        end
      end
    
    end
    
    
  end
end<commit_msg>fixing bug<commit_after>module EAlert
  class TwitterFilter
    
    
    ##
    # By Keywords
    #
    # @param  [String, String, Array]
    # @api    Private
    #
    def self.by_keywords(config, event_name)
      auth      = [config['twitter']['login'], config['twitter']['pass']]
      file      = File.expand_path(::EAlert::USER_CONFIG) + '/tweets' 
      filters   = config['keywords'].split(',').collect! { |w| w.strip }.join(',') # TODO: Sanitize

      `mkdir -p #{file}` unless File.exists?(file)
  
      EventMachine.run do
        http = ::EventMachine::HttpRequest.new("http://stream.twitter.com/1/statuses/filter.json").get(
          :head   => {'authorization' => auth},
          :query  => {:track          => filters}
        )
        http.stream do |chunk| 
          # File.open(File.join(file,"#{Date.today.to_s}_#{event_name}.json"), 'a+') { |f| f.write(chunk) }
          a = ::EAlert::Parse.json(chunk, config)
          STDOUT.puts(a)
        end
      end
    
    end
    
    
  end
end
{'fraction_non_alphanumeric': 0.1706837186424004, 'fraction_numerical': 0.000983767830791933, 'mean_word_length': 2.1534883720930234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '747984', 'n_tokens_mistral': 681, 'n_tokens_neox': 672, 'n_words': 117}