Blue lightsExample of a Bullet Point SlideSlide 3Slide 4Slide 5Slide 6Slide 7What YOU* need** to knowAbout how to munge*** Twitter feeds with Ruby*CMSC 330 Spring 2011**You don't actually need to know about Twitter, just pay attention to the Ruby.***Hideous colour scheme not included (blame Asad Sayeed).Text processing•Ruby: particularly suited for rapid construction of applications that process/produce data streams.• Twitter: an endless “garden hose” of a data stream• Several Ruby libraries written for rapid access to Twitter.– We'll use @SusanPotter's twitter4r libs.GJuliusC #Gallia est omnis divisa in partes 3, quarum 1 incolunt #Belgae, aliam #Aquitani, 3 qui ipsorum lingua #Celtae, nostra Galli appellantur.Installing Ruby libraries/'gems'•Ruby has an Linux-like package install tool.–We WON'T NEED this for most things.–DO NOT USE ON ANY PROJECT UNLESS WE SPECIFY OTHERWISE!!!12!!@!11!!!one!!!!• But if you want to follow along, log into linuxlab and type:gem install twitter4r•Will install a local copy of the twitter4r libs.• Library reference:–http://twitter4r.rubyforge.org/rdoc/Setting up•*If* you want to follow along on your laptop:–Make a dummy Twitter test account (I'll leave it to you to figure out how to do it, but “mailinator.com” may have a role to play...)• Create a config file on linuxlab, config.yamltest:login: SpartacusLives22password: donaferentes– Indent with spaces (it's a YAML file, another thing you don't need to know).•Ruby has lots of builtin libraries. (But we installed our own.)require('rubygems')gem('twitter4r', '0.6.0')require('twitter')• Connectingtwitter = Twitter::Client.from_config(ARGV[0])Starting off the codeLOL @ChanningTatum would never have survived north of the real #hadrianswall #gopictsAnd we're off!•Simple things to try–Download n tweets from arbitrary user–Smiley detection (mood classification?) with regexes•More complicated ones (vote?)– Construct @reply graph– Dijkstra's algorithm between two users (via @replies rather than friends?)– Build Twitter ELIZA!sternvestal im in urimperial #state pardoninur dudes. Remember 2 writecomments in ur code!#vestalvirgin #rubyMoral of the storyTWITTER IS JUST ANOTHER INPUT/OUTPUT STREAM!!!!!YOU CAN DO MAGIC WITH STREAMSIN A FEW LINES OF RUBY CODE(I STILL PREFER PYTHON. --
View Full Document