intro-to-dh

Tuesday + Thursday, 9:30-10:45, 243 Kauke // Dr. Jacob Heil, 158D Andrews Library

View on GitHub

Home. // Assignments/Grading. // Schedule. // Policies.

Mashup Poem Generation

Re-writing The Red Wheelbarrow
HW due Tuesday, 3 APR

The Gist

In class today we breezed through running the script [mashup_madlib.py] that re-creates William Carlos Williams’ poem “The Red Wheelbarrow.” For your homework I’ve asked that you play around with the process: try pulling from different lists (see ingredients, below) to see what comes up.

Copy your favorites into a Markdown document and be prepared to share one of them – and to share your process – in class on Tuesday. Be sure that you’re documenting which lists you’re using to create your favorites. You’ll submit a properly-formatted Markdown document that contains (1) at least 10 created poems that (2) use some combination of at least 6 different lists. Your Markdown file should indicate which lists were used to create each of your poems.

Ingredients

Process

  1. Explore Darius Kazemi’s list of Corpora. (Also check out some of his projecst.)
  2. When you have a list that you’d like to use in your poem mashup, click the “Raw” button in the repository. raw button
  3. Copy the raw URL to your clipboard. raw url
  4. Open mashup_madlib.py in PythonAnywhere.
  5. Paste that URL into line 22 or line 25 or line 28 of mashup_madlib.py
  6. Be sure to change the corresponding line 32, 33, or 34 (respectively) to reflect the name of your new list. Computers are dumb: be smarter than the computer by typing exactly what it expects to see and by honoring quotation marks. change url
  7. Save your file in PythonAnywhere.
  8. To run the Python script, rather than just clicking the “Run” button in PythonAnywhere, we’re going to run our scripts from a command line.
  9. In PythonAnywhere, open your Console and select “Bash”. This will open a “command prompt.” bash
  10. There are many commands you can use to navigate the BASH shell. We’re going to use only a few.
    • pwd (“print working directory”)
    • ls (list files and directories in current working directory)
    • cd ______ (change directory) EXAMPLE: $ cd mashup_madlib moves you from the current working directory, “down” a level, into the directory called “mashup_madlib”. To navigate back “up” a level, you enter $ cd ..
    • python ______.py (tells the shell to run the Python compiler in the command line.) EXAMPLE: 18:44 ~/mashup_madlib $ python mashup_madlib.py will run the python script named “mashup_madlib.py” in the BASH shell using the Python compiler. BUT you have to be in the mashup_madlib directory (if you’re not sure, pwd.)
    • Protip: If you’re a visual learner, like me, remember that “directory” is conceptually the same as a folder in windows-based systems: it’s a container for files and folders.)
  11. So, when you open the shell for the first time, type cd mashup_madlib and then type ls. You should at least see the name of the script we need, mashup_madlib.py.
  12. As long as you see that file name, you can then type python mashup_madlib.py and the script will write poems to the BASH console.
  13. As you do this, copy your favorites from the console into a markdown file of your creation so that you can make sure to save your favorites. Also, as you’re iterating, make sure you’re keeping track of the lists you’re using to cerate each poem.
  14. Return to STEP TWO to try it all over again with new lists.
  15. Protip If you press the ^ arrow key (not the caret) in the BASH console, you can cycle through your previous commands rather than typing python mashup_madlib.py every time.

Booking Meetings


Course Archive: 2017

Creative Commons License
An Introduction to Digital Humanities by Jacob Heil is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.