Skip to content

Instantly share code, notes, and snippets.

@thekarladam
Created November 7, 2010 22:42
Show Gist options
  • Save thekarladam/667081 to your computer and use it in GitHub Desktop.
Save thekarladam/667081 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'tweetstream'
@statuses = []
@keywords = {}
TweetStream::Client.new("MikeyMcTesty", "password9").track(ARGV) do |status, client|
statusText = status.text
puts "\t#{status[:user][:screen_name]}:\n\t #{statusText}\n"
words = statusText.split(" ")
words.each do |aWord|
if aWord.length > 3 && !ARGV.include?(aWord)
returnedCount = @keywords[aWord.downcase]
if !returnedCount
returnedCount = 0
end
returnedCount += 1
@keywords[aWord.downcase] = returnedCount
end
end
@statuses << status
client.stop if @statuses.size >= 10
end
@keywords.reject{|key, value| value == 1}.sort {|a, b| a[1] <=> b[1]}.reverse.each {|a, b| puts "\"#{a}\"\t => #{b}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment