Count the occurrences of words in a tweeter's tweets.
Configurable - set the words to ignore, the range of dates to look at, and whether to include hashtags, @-mentions, and URLs. Customize your Twitter configuration, too. Sensible defaults are provided for all options. Look at the data in different ways. Easily convert and/or export to CSV and JSON. Change configuration options on the fly and re-audit with ease.
Installation
Add this line to your application's Gemfile:
gem 'twords'
And then execute:
$ bundle
Or install it yourself as:
$ gem install twords
Documentation
http://rdoc.info/gems/twords
Usage
Twords takes a configuration block, and if it doesn't find one it will set the following defaults:
Twords.config do |config|
config.rejects = %w[my us we an w/ because b/c or are this is from
be on the for to and at our of in rt a with &
that it by as if was]
config.range = 30
config.include_hashtags = false
config.include_uris = false
config.include_mentions = false
config.up_to { Time.now }
config.twitter_client do |twitter|
twitter.consumer_key = ENV['TWITTER_CONSUMER_KEY']
twitter.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
twitter.access_token = ENV['TWITTER_ACCESS_TOKEN']
twitter.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
end
end
twords = Twords.new 'user_one', 'user_two'
twords.audit
twords.words
twords.words_forward
Twords.config { |config| config.include_hashtags = true }
twords.audit
twords.words
twords.audit!
twords.words
Other useful methods:
twords = Twords.new 'user'
twords.audit
twords.tweets
twords.total_word_count
twords.percentages
twords.sort_percentages
twords.to_[csv|json] # Generate CSV || JSON for results
twords.write_to_[csv|json](opts)
Development
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/msimonborg/twords.
License
The gem is available as open source under the terms of the MIT License.