ENGL539 Designer Blog: Word Cloud

In preparation for my final project reflection, I made a word cloud of my designer blog:

Screen Shot 2015-05-04 at 1.32.19 PM

The most used words aren’t surprising, although I think it’s funny that “really” is one of the top words—I think that might be a result of how strongly I felt about coding (frustrated). “Basic,” “found,” and “tried” highlight the exploratory nature of the project. I’m surprised “hard” wasn’t used often…I suppose that I was trying to stay optimistic about the whole thing!

Advertisements

ENGL539 Designer Blog: (AP)I need a code

I’m updating one more time before the project is due, because clearly by my last post I was not anywhere close to having a viable code to show for the final project. According to my proposal, my code should have been perfected by 4/24/15, but I abandoned hope of that long, long ago.

Via my Googling, I found this blog, explaining how to collect tweets using Tweepy. I didn’t fully understand Tweepy, but from there, I learned that there’s a difference between a “Rest” and a “Streaming” API. From the descriptions, I learned that I would need a Rest API, and from there I found a line of code that would do exactly what I need, called GET statuses.

Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters.

The site doesn’t really explain how to use it in context. Based on their example request line of code, I tried:

Screen Shot 2015-05-04 at 10.48.11 AMUnfortunately that did not work.

I went through some tutorials trying to find any that may have used that function. I didn’t see any, but I noticed that all of them had this code at the top that somehow authenticates your bot. I tried including that as well to see if it worked (spoiler alert: it didn’t).

Screen Shot 2015-05-04 at 10.51.05 AM

With a week left, I’m going to spend my time playing around with Tweepy API tutorials. I still haven’t made the jump from Dan’s tutorial on how to have bots produce work to my own goal of having bots collect work. If I figure that out, I’ll be satisfied!

ENGL 539 Designer Blog: IT’S ALIIIIIIIVEEEE (I Made a Bot)

Last week on 4/13/14, our Second Tutorial assignment was due. That forced me to get on track with my coding tutorial and put some of my knowledge to use. I was really happy with how it turned out! It was very basic code, and I’m sure I didn’t go about it in the cleanest, easiest way possible, but I wrote it from scratch and consider that in and of itself a huge accomplishment. Once I had gone through the first few chapters of the coding tutorial, I was able to start Googling smartly. By that I mean I had the basic jargon down, and had a better idea what search terms I should use to get the results that I want.

I still wasn’t sure how to go about applying the code (once I got it) to Twitter to start grabbing tweets for me. Luckily, in class last week we were in groups discussing the progress of our projects, and Dan mentioned that he has a tutorial on Twitter bots. I saw him post it on Facebook, but a. I didn’t know that a bot could do what I was asking—I associate them with Twitter profiles that interact with other users and produce things an b. I was hoping to start from scratch and figure it out on my own so I could understand the logistics of it. That definitely was not working, so I tried out the tutorial.

It went really well! It was very simple—I still ran into problems, but they were Google-able. For example, he instructs to install “tweepy” by using the line:

pip install tweepy

I kept receiving the error message:

-bash: pip: command not found

After a little searching, I found out that “pip” (whatever that is) does not come automatically installed with the version of Python I was using. I tried to manually install it, but after failing, just upgraded my version of Python and it was fixed! Finally, I got the bot to work:

Screen Shot 2015-05-03 at 11.07.32 AMBot results

My aim is to collect data, rather than reproduce tweets, but this was an excellent introduction to bots…now I have a better idea of what I’m working with, and how I use the code to make it do things. I am still woefully behind on having a code ready, but this tutorial introduced me to Tweepy, and I’ve seen a few tutorials about using it to data mine, so I think I’m getting closer.

ENGL 539 Python Tutorial: Create Your Own Mad Libs

A note on resources: This tutorial was created on Mac OS X Version 10.9.5. I used the default pre-installed version of Python, version 2.7.5. I used Apple’s pre-installed Terminal application and Bare Bones Software’s free TextWrangler download.

  1. Open TextWrangler
  2. Enter # -*- coding: utf-8 -*- to allow for unicode characters. I had trouble with question marks and semicolons causing errors when running my code; this discussion seemed to fix the problem.
  3. Determine which parts of speech you will be replacing in your text for the Mad Lib. Start simple; for this tutorial, I replaced singular nouns, present tense verbs, adjectives, and adverbs.
  4. Define the part of speech
    1. Type the part of speech label
    2. Type = to indicate the words it will representScreen Shot 2015-04-13 at 3.06.55 PM
    3. Type your values between brackets [ ]Screen Shot 2015-04-13 at 3.07.16 PM
    4. Each value should be enclosed by quotation marks ” “Screen Shot 2015-04-13 at 3.07.27 PM
    5. Separate each value by a comma outside of the quotation marks “,Screen Shot 2015-04-13 at 3.07.37 PM
    6. Repeat for each part of speech you are defining; each list should be on a different line (example below)Screen Shot 2015-04-13 at 4.11.40 PM
  5. Type import random on a new line to import the module that will allow for you to randomize your textScreen Shot 2015-04-13 at 3.07.58 PM
  6. Paste your text on a new line and format. You can use any text, or create your own!
    1. Type print in front of your textScreen Shot 2015-04-13 at 3.09.57 PM
    2. Ensure the text is between quotation marks – this will ensure it appears as-is when the code is runScreen Shot 2015-04-13 at 3.11.04 PM
    3. Consider separating your text into multiple lines, if it is not already, in order to make the code readable
    4. Edit your text to suit the code. Ensure that \ are properly added to words with apostrophes or quotation marks that you would like to print when the code is run. Ensure all apostrophes/quotations are opened and closed properly. Ensure each line has “print” in front of it.Screen Shot 2015-04-13 at 3.12.49 PM
    5. Replace the words with the name of the part of speech in all caps and exclude them from the parentheses enclosing the string. This is so you can easily identify where you will paste the code for the random text generator.Screen Shot 2015-04-13 at 3.26.25 PM
    6. You can take this opportunity to paste in the random.choice code from step 7a, however I suggest waiting so that you can easily review the words that you removed.
    7. Ensure that the words you are replacing match the tense; for example, do not replace a plural noun if the words in your noun list are singular.
  7. Enter the randomization code into your text
    1. Replace the parts of speech in the text with random.choice(part of speech)
    2. Separate the random.choice code from the string of text with a comma
    3. Enclose the word before and and the word after the random.choice code with a quotation mark.Screen Shot 2015-04-13 at 3.34.21 PM
    4. Here is an example of the final code:Screen Shot 2015-04-13 at 3.34.09 PM
  8. Run your code through Terminal by opening the directory where your TextWrangler file is saved typing python filename.pyScreen Shot 2015-04-13 at 3.36.49 PM

Here is what the code looks like in its entirety:

Screen Shot 2015-04-13 at 3.40.35 PM

Here are a few examples of the results:

Screen Shot 2015-04-13 at 2.17.53 PM Screen Shot 2015-04-13 at 4.28.36 PM Screen Shot 2015-04-13 at 4.28.53 PM

ENGL539 Designer Blog: My Proposal Timeline is a Joke

So I turned in my official project proposal on 3/30/15, anddd I’m already off track. I vastly overestimated how quickly I’d get the language. I was basing my time estimations off of when I learned HTML a few years ago…I remember thinking it was really easy as I Googled everything. This is way more complex.

I started going through the Harrison video referenced in my last blog (and stated in my proposal that the tutorial would be done by 4/2/2015), however I just couldn’t get through it. I was lost within the first five minutes when he mentioned importing “cookielib” in the third line of code and didn’t explain further. Google couldn’t even give me a good explanation of what it was. The tutorial assumed you had some basic knowledge about Python, and it was tedious to keep googling along. From the Python beginner’s wiki, I found a very basic tutorial called Learn Python the Hard Way by Zed Shaw. It started as small as teaching how to become comfortable with Mac’s Terminal and TextWrangler, so I feel good about it. It’s very similar to Code Academy; the author strongly encourages readers to follow along and write out the code, even if it’s super basic. I feel much more comfortable with this format over a video tutorial. Unfortunately, I’ll need to take the time to go through Shaw’s book, and in my Proposal I projected that I’d be manipulating some form of my final code by now. Coding is hard 😦

ENGL 539 Designer’s Blog: Making the Switch to Python

I officially abandoned Ruby and made the switch to Python. I’ve been Googling around and have found a lot more information about Python in regards to data mining from Twitter, so I think that despite my Ruby technical difficulties, I would have ended up with Python regardless. I made the mistake of approaching the language from a “what will be easier to learn” perspective rather than a “how easy is it to find tutorials/information” perspective. In reality, I’m starting with pretty much nothing, so I don’t think one will be “easier” for me than the other. Python also seems more beginner-friendly—I just noticed that they have a whole wiki for non-programmer beginners on their site.

Since I wasted the first Tutorial Assignment on a language that I’m not using, I decided to start by finding a Python tutorial to make up for it. I came across this one, explicitly discussing how to use Python for Twitter analysis.


I still do not have the basic language, so I plan on spending some time on the wiki offered by Python in order to get a sense of what I need to learn before jumping into the tutorial.

ENGL539 Designer Blog: Finding a Language

I’ve decided that my project will be to create a tweet-gathering algorithm, and I’ve spent my time   working with Ruby trying to get it to work. I started out last week at the very basic level of learning the differences between coding languages, and which ones were even capable of being used to gather tweets. Surprisingly (and dishearteningly), even this proved difficult. I’m realizing that I don’t even have the basic language to understand coding. I came across a few questions on forums asking about Ruby versus Python for Twitter, so I narrowed my potential coding languages down to those two. I’m still too much of a novice to really appreciate the differences between them, and there isn’t really a consensus which is “better,” but I came across this chart where Twitter is listed under “Ruby” for usage.

Ruby_vs._Pythonvia http://learn.onemonth.com/ruby-vs-python

On 3/2/15, our First Tutorial assignment was due. I completed a few modules in Lynda.com of a Ruby for Beginners tutorial. It was very easy to understand, and I was feeling good about my choice, but I couldn’t get it to instal on my computer! The tutorial said that Macs come standard with Ruby, but mine didn’t seem to recognize it.

Screen Shot 2015-05-04 at 9.36.10 AM

My terminal is just blank when I try to locate it

I also tried downloading it, but nothing really happened with the installation. My computer does, however, come pre-loaded with Python, so I am leaning towards making the switch, since my heart wasn’t really set on either one anyways.

Screen Shot 2015-05-04 at 9.37.56 AM

I have no idea what that Ruby file is, but it’s not showing up in the terminal!

ENGL539 Designer Blog: Project Ideas

For my final project I am hoping to create a tweet-gathering algorithm. The idea was suggested by Dan during a class activity in our ENGL685 Writing Research class, where I am researching humor on twitter. Part of my project will involve gathering tweets from a few selected public accounts. I am limiting myself to 10 tweets over a one month span for three different accounts. However, if it is possible for me to learn how to create an algorithm within the time frame of this semester, I would be able to greatly expand my data pool for the research.

So far I’ve tried a few Google searches and found a good overview explaining the fundamentals of algorithms and where to get started. There also seem to be courses on Lynda.com, and I will use next week’s tutorial assignment to take a more in-depth look at if it is possible to create something like this as a coding novice.

My back-up idea, should the algorithm not work out, is to learn how to design and create a hyperlinked e-book. We have read some material in this class arguing that non-linear reading has a number of advantages, such as allowing readers agency over the text. Most of the examples we’ve seen have been informational, such as Wikis. I wondered, if hypertext had somehow been available at the advent of storytelling, if the linear structure of storytelling would have prevailed. I thought it might be interesting to adapt a classic piece of literature as a hypertext document in the format of an e-reader, which are increasingly becoming commonplace. A Google search tells me that others have added hypertext to classics, such as this version of Pride and Prejudice. Another idea would be to take a piece of fiction that was written as a hypertext story, analyze any shortcomings consumers may have complained about in online reviews, and determine if it is possible to re-adapt the story to account for any shortcomings. That may not be feasible as the project may infringe on copyright laws.