Tutorial: Twitter Bots

00

UPDATE 9/14: A few things have changed for setting up a Twitter application since this tutorial was written. The main change is you will need a phone number to register your app. Most of this guide should be fairly close to the current system, though the screenshots may look a bit different.

Creating Twitter bots, automated text-generators that spew spam, poetry, and other things, can be a bit of a confusing process. This tutorial will hopefully get you through the tough bits and make bot-building possible!

For this tutorial I will be using Python, a language whose simplicity and natural syntax is great for working with text. However, this tutorial should be easily portable to your language of choice. I assume you know at least enough programming to write your own algorithmic text; if you need some help, I would suggest one of the myriad resources including Learn X in Y Minutes. Finally, this post is written from a Mac user’s perspective – if you use another OS and have suggestions or required different steps, my apologies and let me know so I can add them.

If your programming is not up to snuff, you might consider using IFTTT to trigger a Tweet. While the range of possible text is much more limited, you can easily do things like post a Tweet when tomorrow’s weather is forecasted to be nice or you like a video on Vimeo! (You can also use this as a backup for storing your bot’s awesome Tweets.)

You can view the source files used here, screenshots, and other miscellany for this tutorial on GitHub.

Continue reading “Tutorial: Twitter Bots”

Three New Twitter Bots

RandomChordBotScreenshot

Yesterday I released three Twitter bots into the world:

  1. @wouldratherbot posts randomized “would you rather” questions, such as “Would you rather etch a hat or edit an acceptance?” and “Would you rather standardize an appellate or reject a counter?” – code for the bot here
  2. @randomchordbot generates all 40,920 chords in the first 5 frets of the guitar, one per hour (see an example at the top) – code for the bot here
  3. @artassignbot creates randomized art assignments and due dates anywhere between 10 seconds and 10 years from today, for example “Create a flipbook examining your relationship to food, due on Sat, Nov 22, 2014” and “Construct an etching examining the history of memory, due in 36 seconds” – code for the bot here

Grid Remix: Fellowship Of The Ring

GridRemix_ LordOfTheRings_Cover-web

Having sequestered myself for the last week, immersed in regex and InDesign, I have finished my novel for National Novel Generation Month. Code and further details available here.

The book was created algorithmically using custom software written in Python and Processing. J.R.R. Tolkien’s 1954 classic The Fellowship of the Ring was loaded word-by-word then organized into a two-dimensional grid. From a random start position in the grid, the “cursor” was moved up, down, left, or right and that word added to the new text.

The process was repeated until 50,000 words was reached, the length of an average novel.

Random commas, periods, paragraph breaks, and chapters were added along the way. Any sentence including a variation of the words “s/he said” was placed in quotes.

Continue reading “Grid Remix: Fellowship Of The Ring”

Random Walk Through A Novel

RandomWalkThroughLOTR

A test for #NaNoGenMo, or National Novel Generation Month, initiated by Darius Kazemi.

An existing text is loaded word-by-word, then organized into a 2d grid. Using a random start position in the grid, the “cursor” is moved up, down, left, or right and that word is added. The process is repeated up to 50k words. Random commas, periods, and paragraph breaks are also added along the way.

An excerpt, using “Tale of Two Cities” as a source text (the random walk is visualized above):

Jurys upon pay thousand one and one. Thousand were I than tried He tried than I were thousand seven, now were and than. I, were and than and were, thousand one. November before and were now turned now were now turned done to explain to. Tried than tried than better. Than and, before better before and were I to the to explain to when time.

More. Remarkable more remarkable of remarkable of lawwork no lawwork to do Dont. Do too Lord too Lord inquired of living in London in London in London, arisen to arisen and do to how. Known not known where up did seventyfive, stood seventyfive stood seventyfive did seventyfive stood up did up where business did seventyfive. Stood seventyfive stood had, not that not had stood again and Was, all unless the prisoners that had it had passing arts and thought of powers of thought been more knew was knew they knew. More slowly the slowly. The slowly nothing about the and the about nothing taken off about off taken, prisoner in off taken off That the. That. The about nothing about nothing taken off about the about nothing slowly. Nothing knew they been. They. That had it Some it had passing thought and powers of the slowly the infamy the of selfdeceit infamy selfdeceit of.

Another example, with repetition allowed (LOTR as source):

Help would help would help would judgement For help for help help for them, for who would judgement For For help For even even even even, the even it at looked and and, and again death death friends who who who in death out pocket out death out death death friends friends friends task easy easy an first an fine, deal his pocket his of his of of chosen and his deal his deal fine fine his first first his were him him were There There tracked tracked that find is. Begins to grip But as as far far as as But too too clear Making far far far as to as as out as task friends task friends who who for who who for them them for for Gollums out as.

Source code and texts here: https://github.com/jeffThompson/NaNoGenMo

Every Unique Word in ‘usenet-com’

A list of every unique word in the ‘usenet-com’ Usenet archive from Internet Archive. Warning: very long post!

_
___
_____________________________
_______________________________________
___________________________________________________
_______________________________________________________
________________________________________________________
__________________________________________________________________
__________eavesdropping____________________
_mn_main
?
?
??
?99
?berweisen
?berweisungstr?
?e
?gen
?ger
?line
?mchen
Continue reading “Every Unique Word in ‘usenet-com’”

Most Frequent Word Search

For the past few months I’ve been working on a curatorial project with the Internet Archive, to be released on their Tumblr account early next year. One of the experiments for this project searches the Internet Archive for a given term, downloads the first result, parses the most frequent word and uses that as a seed for the next search. For example:

seed > plants > leaves > chinese > heaven > minerva > questo

An interesting result: this process goes from general to more and more specific until no search results are found. This is actually an interesting opposite of my Wikipedia Loops project, where a similar algorithmic path goes from specific to general, eventually falling into a meta-loop.

The code for this experiment is available here: https://gist.github.com/jeffThompson/6718129

PDFs of Brightness, Sorted by Brightness

BrightestDarkest

As an early experiment for a curatorial residency with the Internet Archive, I wrote some software that searches for all PDF texts on the site that contain the word “brightness” in their title or description, downloaded the files (approximately 900 PDFs), analyzed them and sorted them by overall brightness.

Above are the first pages of the brightest and darkest PDFs – a table with all the files and URLs is after the break. Download the source code here.

Continue reading “PDFs of Brightness, Sorted by Brightness”

Wireless Networks: Hoboken to Glen Ridge

A list of wireless network names, gathered on NJ Transit between Hoboken and Glen Ridge, New Jersey, USA:

Continue reading “Wireless Networks: Hoboken to Glen Ridge”

Installing OpenCV on Mac

UPDATE: Mavericks users were likely frustrated for the last few weeks trying to install OpenCV. It appears the problem has been fixed, and these instructions should work without issue.

My previous post on installing OpenCV for Mac users is one of the most popular on this site (which is simultaneously surprising and fantastic). However, I recently switched from using MacPorts to Homebrew – users that need to migrate existing installs can check out this guide.

Still complicated but thoroughly do-able, here is how to install OpenCV on a Mac running Mountain Lion:

  1. Open Applications > Utilities > Terminal…
  2. Install Homebrew by typing the following into Terminal
  3. Run the command brew doctor to check for any errors
  4. While normal installations using Homebrew are very straightforward, for some reason OpenCV requires an extra step – you need to install an add-on called science:
  5. Then you can run the usual Homebrew command to install OpenCV:

    If this fails, it may be that you have ffmpeg installed – if so, try this instead:
  6. This may take several minutes, so be patient!
  7. Homebrew may tell you that you have to update  PYTHONPATH  – if so, open your favorite text editor, click File > Open… and hit command+shift+. to see hidden files
  8. Navigate up to your home folder and open the  .bash_profile  file – if it doesn’t exist, create it yourself
  9. Add the line suggested by Homebrew, probably something like:
  10. Save the file and close it – you may also have to exit Terminal and open it again
  11. Test by opening Python:

    Then try to import OpenCV:
  12. If you don’t get any errors, you’re all set! Now go enjoy a real beer!

Hope this helps! Problems, suggestions – leave them in the comments.

English Language File Extensions

Having just wrapped up a long project, I’ve wasted much of this morning on a dumb little idea: compiling all file extensions that are also valid words in the English language. Using a Processing sketch to scrape the website filext.com, then a Python script running the Natural Language Toolkit to check against the dictionary.

Not perfect (some acronyms made their way through) and could be better (separate files for parts of speech, making it easier to build texts).

Also included is a random poem builder – here’s a sample:

BD SETUP DREAM
al vat 100 works tb nob aim name press beacon xes sod code atm four arm
tao play hairy mob whiz medical ipod exs or
ews bh lxs session poem wax serial locked primer
ybs erasure rummy ascii tis hiv sparse driver spiff pic video 98 amos first
rip
arp tree ad watch
rummy colors
wus ebs mo
clearance pip pro english ph idea messenger monday wmo ism
milk sequence
caps fat correct pub three blocks 110 more blue hdl saw value m start holly
fez tnf male chorus kvs kick vac frame nrc
night lsd resource arcane arch bks

Code and resulting data is available on GitHub; full CSV results after the break.

Continue reading “English Language File Extensions”