Introduction to Computational Literary Analysis, Summer 2018
- Instructor: Jonathan Reeve
- Room: D-Lab Collaboratory, 356 Barrows Hall
- Office: Barrows Hall Room 350J
- Office Hours: Fridays, 12pm-2pm, or by appointment
- Email address: email@example.com
- Course website: https://github.com/JonathanReeve/course-computational-literary-analysis
- Course chatroom: https://gitter.im/course-computational-literary-analysis/Lobby#
- Readings: https://course-computational-literary-analysis.netlify.com/
This course is an introduction to computational literary analysis, one which presumes no background in programming or computer science. We will cover many of the topics of an introductory course in natural language processing or computational linguistics, but center our inquiries around literary critical questions. We will attempt to answer questions such as:
- Did Shakespeare write the so-called Shakespeare apocrypha plays?
- What are the characteristic speech patterns of the narrators in Wilkie Collins's The Moonstone?
- What words are most frequently used to describe Katherine Mansfield's female characters?
- Which novels of the nineteenth century are the most similar to each other? Which are the most different?
The course will teach techniques of text analysis using the Python programming language. Special topics to be covered include authorship detection (stylometry), topic modeling, and word embeddings. Literary works to be read and analyzed will be Wilkie Collins's The Moonstone, Katherine Mansfield's The Garden Party and Other Stories, and James Joyce's Dubliners.
Although this course is focused on the analysis of literature, and British literature in particular, the skills you will learn may be used to computationally analyze any text. These are skills transferable to other areas of the digital humanities, as well as computational linguistics, computational social science, and the computer science field of natural language processing. There are also potential applications across the humanistic disciplines—history, philosophy, art history, and cinema studies, to name a few. Furthermore, text- and data-analysis skills are widely desired in today's world. Companies like Google and Facebook, for instance, need ways to teach computers to understand their users' search queries, documents, and sometimes books. The techniques taught in this course help computers and humans to understand language, culture, and human interactions. This deepens our understanding of literature, of our fellow humans, and the world around us.
This course presumes no prior knowledge of programming, computer science, or quantitative disciplines. Those with programming experience, however, won't find this boring: the level of specialization is such that only the first week covers the basics.
The best resource for this course is the course GitHub repository. That repo will always contain the most up-to-date copy of this course syllabus, which is subject to change. We will also have a Gitter chatroom for any questions you might have along the way, especially those that you think might be able to be answered by other students. Check out what's happening on Gitter as often as you can, and ask any questions you have there, first. You'll probably have to sign up for Gitter with a GitHub username, if you don't already have one. Unless you're already well established on GitHub, please use your real name as your GitHub/Gitter username. (Mine is JonathanReeve, for example.)
If you want a second opinion about a question, or have questions that we can't answer in the chatroom, a good website for getting help with programming is StackOverflow. Also, the Internet is full of Python learning resources. One of my favorites is CodeCademy, which has a game-like interactive interface, badges, and more. If you like a good puzzle, and like being challenged, there's also the older Python Challenge.
Resources related to text analysis include, but are by no means limited to:
- The NLTK Book
- My introduction to text analysis tutorial
- My advanced text analysis tutorial with SpaCy
Coursework falls into three categories:
- Annotations (30% of final grade)
- Homework (30% of final grade)
- Final project (40% of final grade)
Additionally, there are three course readings: one novel and two short story collections. Reading these closely will help you to contextualize the quantitative analyses, and will prepare you for the close reading tasks of the final paper.
All readings will be provided in digital form on the course GitHub repository, but if you prefer to read on paper, or to supplement your reading with background information and critical articles, I highly recommend the Broadview and Norton Critical Editions:
- Wilkie Collins, The Moonstone, Broadview Edition
- Katherine Mansfield, The Garden Party and Other Stories, in Katherine Mansfield's Selected Stories, Norton Critical Edition
- James Joyce, Dubliners, Norton Critical Edition
For each reading assignment, please write at least two annotations to our editions of the text, using hypothes.is. Links are provided below. You'll have to sign up for a hypothes.is account first. As above, please use your real name as your username, so I know who you are. You may write about anything you want, but it will help your final project to think about ways in which computational analysis might help you to better understand what you observe in the text. Good annotations are:
- Concise (think: a long tweet)
- Well-written (although not too formal)
- Observant (rather than evaluative)
You may respond to another student's annotation for one of your two, if you want.
Four short homework assignments, of 3-10 questions each, will be assigned weekly, and are due on Monday the following week. Jupyter notebook templates for each will be provided. Since we'll review the homework answers at the beginning of each week, late work cannot be accepted. There will be no homework due on the Monday of the last week, to give you more time to work on your final projects.
Submit homework to me at my email address above.
Final Project / Paper
The final project will be a literary argument, presented in the form of a short academic paper, created from the application of one or more of the text analysis techniques we have learned toward the analysis of a text or corpus of your choosing. Should you choose to work with a text or corpus other than the ones we've discussed in class, please clear it with me beforehand. Your paper should be single a Jupyter notebook, including prose in Markdown, code in Python, in-text citations, and a bibliography. A template will be provided. The length should be about the equivalent of an 6- to 8-page printed paper. You're allowed a maximum of three figures, so produce plots selectively. A word count function will be provided in the Jupyter notebook template.
During the final week of class, we'll have final project presentations. Your paper isn't required to be complete by then, but you'll be expected to speak about your project for about 5-7 minutes. Consider it a conference presentation.
Final papers will be evaluated according to the:
- Quality of the literary critical argument presented
- Quality of the close readings of the text or corpus
- Quality of the Python text analysis
- Literary interpretation of the results
- Integration of the computational analysis with the literary argument
As with homework, please email me your final projects. You may optionally submit your final project to the course repository on GitHub, making it public, for a 5% bonus.
Attendance is crucial. Although most course materials will be published in the course GitHub repository, they cannot replace hands-on experience with the techniques this course teaches. This is doubly true of in-class discussions of our readings. If you can't make it to a class for some reason, please let me know in advance, and arrange to get notes from a classmate.
Week 1: Introduction to Python for Text Analysis
Text: Wilkie Collins, The Moonstone Tools: Python (Anaconda)
- Unit 1.1: Course intro. Motivation: what is possible with computational literary analysis?
- Unit 1.2: Installing Python. Python 2 v. 3. Jupyter. Strings.
- Unit 1.3: No Class: Independence Day Holiday
- Unit 1.4: Working with strings, lists, and dictionaries.
Week 2 (7/9-7/13): Basic Text Analysis
Text: The Moonstone, Continued Tools: Natural Language ToolKit (NLTK)
- Unit 2.1: Review of Week 1 and Homework 1. Loading and manipulating plain text files.
- Text: First Period, Complete.
- Homework 1 due
- Unit 2.2: Working with words. Tokenization techniques. Lemmatizers.
- Unit 2.3: Basic text statistics with the NLTK. Type / token ratios. Loops, functions, and other control structures.
- Unit 2.4: More text statistics. Concordances, collocations, dispersion plots.
Week 3 (7/16-7/19): Word Frequency Analyses
Text: The Moonstone and Katherine Mansfield, The Garden Party and Other Stories Tools: Scikit-Learn, Pandas
- Unit 3.1: Review of Week 2 and Homework 2. Numpy, Pandas, and narrative time.
- Homework 2 due
- Text: Second Period, Fourth and Fifth Narratives
- Unit 3.2: N-grams and part-of-speech analyses.
- Text: The Moonstone, Complete
- Unit 3.3: WordNet and WordNet-based text analysis.
- Texts: "The Garden Party"
- Unit 3.4: Downloading, using, and iterating over corpora.
Week 4 (7/23-7/26): Linguistic Techniques I
Text: Katherine Mansfield, The Garden Party and Other Stories Tools: NLTK, SpaCy
- Unit 4.1: Review of Week 3 and Homework 3. Corpus vectorization with Scikit-Learn. TF-IDF. Stylometry.
- Unit 4.2: Comparative stylometry. Corpus-DB.
- Unit 4.3: Stylometry, continued.
- Unit 4.4: Topic modeling with LDA. Quote parsing.
Week 5 (7/30-8/2): Linguistic Techniques II
Text: James Joyce, Dubliners Tools: SpaCy
- Unit 5.1: Review of Week 4 and Homework 4. Using SpaCy. Named entity recognition.
- Unit 5.2: Intro to final project. Sentiment analysis. Macro-etymological analysis.
- Unit 5.3: Sentence structure analysis using SpaCy.
- Unit 5.4: Extras: TEI XML, APIs
Week 6 (8/6-8/9): Advanced Topics
Text: James Joyce, Dubliners Tools: Scikit-Learn, SpaCy