twitter_networks
twitter_networks
A library for tools to create Twitter Networks in Crystal. In progress.
Feel free to contribute with any features you see fit! I'm looking to add some community detection algos and stuff.
Possible Inspirations:
- Clustering and Community Detection in Directed Networks
- Community Detection in Political Twitter Networks using Nonnegative Matrix Factorization Methods
Installation
Add this to your application's shard.yml
:
dependencies:
twitter_networks:
github: akarimcheese/twitter_networks
Usage
require "twitter_networks"
Creating a Network Instance
network = Network.new(
ENV["TWITTER_CONSUMER_KEY"],
ENV["TWITTER_CONSUMER_SECRET"],
ENV["TWITTER_ACCESS_TOKEN"],
ENV["TWITTER_ACCESS_SECRET"]
)
Add users to network
network.add_users(["JODYHiGHROLLER", "KimKardashian", "BarackObama", "BillGates"])
puts network.graph.inspect
# {"JODYHiGHROLLER" => ["KimKardashian", "BarackObama", "BillGates"], "KimKardashian" => ["BarackObama"], "BarackObama" => [], "BillGates" => ["BarackObama"]}
Print a message when Twitter rate limits occur
network.on_rate_limit {
puts "Twitter Rate Limit reached. Sleeping for 5 minutes..."
}
Print a message as a follower-followed relationship is found in add_user()
/add_users()
network.on_relationship_found { |follower, followed|
puts "Twitter Networks has found that #{follower} follows #{followed}!"
}
network.add_user("JohnCena")
# Twitter Networks has found that JODYHiGHROLLER follows JohnCena!
# Twitter Networks has found that JohnCena follows KimKardashian!
# Twitter Networks has found that JohnCena follows BarackObama!
# Twitter Networks has found that JohnCena follows BillGates!
Get the network as a csv string
network_csv = network.to_csv_string
File.write("network.csv", network_csv)
Development
TODO: Write development instructions here
Contributing
- Fork it ( https://github.com/akarimcheese/twitter_networks/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- akarimcheese Ayman Karim - creator, maintainer
Repository
twitter_networks
Owner
Statistic
- 0
- 0
- 0
- 0
- 1
- almost 7 years ago
- October 4, 2017
License
MIT License
Links
Synced at
Mon, 23 Dec 2024 06:37:32 GMT
Languages