**Course Outline
**Since the invention of the printing press, the written word is the most common format by which knowledge is transferred. Computational linguistics has seen dramatic changes and some tools are very useful for applied economics and public policy research. This course will introduce students to quantitative text analysis methods and concepts and illustrate their application using examples drawn from text corpora that may be commonly used in public policy analysis, such as legislative texts or political speeches. We will work with conventional statistical and heuristic methods to summarize and compare coropra of text and extract information. However, we will also draw on a range of supervised and unsupervised machine learning methods to perform clustering and classification tasks, and illustrate their application in applied public policy research. The course will introduce students to the art of programming with R.

**Prerequisites
**There are no programming or machine learning prerequisites for this class. Students with significant programming experience may choose an accelerated pace through the introductory materials presented in the class at their discretion.

**Course Hours **

**What? Quantitative Text Analysis Lectures**

**When? every Thursday 3-5:50 pm**

**Where? Room 140C.**

**Piazza**

This term we will be using Piazza for class discussion. The system is highly catered to getting you help fast and efficiently from classmates, the TA, and myself. Rather than emailing questions to the teaching staff, I encourage you to post your questions on Piazza. If you have any problems or feedback for the developers, email team@piazza.com.

Find our class page at: piazza.com/uchicago/spring2017/ph30570/home

**Grading
**Pass/Fail allowed. The final grade will be based on: 1) class attendance and participation in discussions (20%); 2) programming assignments (50%); 3) results of a

**(30%).**

*group project***Recommended Reading**

There is no single text book covering the material we discuss in the course. I will post recommended readings for each week – the books are available for free electronically.

[IIR] Manning, C. D., Raghavan, P., & Schütze, H. (2008). *Introduction to Information Retrieval*. New York, NY, USA: Cambridge University Press.

[ISLR] James, G., Witten, D., Hastie, T., & Tibshirani, R. (2013). An Introduction to Statistical Learning (Vol. 103). New York, NY: Springer New York.

[SLP] Jurafsky, D., & Martin, J. H. (2000). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition (1st ed.). Upper Saddle River, NJ, USA: Prentice Hall PTR.

## Topics Covered

**Part 1: Introduce simple NLP concepts, introduce the R language and illustrate how we can work with getting text into a useful format for subsequent analysis. The unit of analysis in the first part of the course will mainly be (short) sequences of words.**

- Introduction: Motivation, setting up, examples, basic introduction to “R”.
**Reading**and stuff to do: RStudio Installation, An Introduction to R , Getting Started with Markdown in Rstudio**Slides****Homework 1, Homework 1 marks**

- Sourcing data: String manipulation, regular expressions, loading text data, basic web scraping, (social media) API’s.
**Slides****Reading**and stuff to do: Regular Expressions in R, Another nice Regex introduction**Rcode for Week 1**

- Text Normalization: Zipf’s law, Herd’s law, tokenization methods and routines, stemming, Levenshtein distance.
**Reading**: [SLP], Chapter 2, http://web.stanford.edu/~jurafsky/slp3/2.pdf

- Slides

- Describing Text: readability measures
- Identifying and extracting collocations: heuristic and statistical methods.
**Reading**, [IIR], Chapter 5, http://nlp.stanford.edu/fsnlp/promo/colloc.pdf; Optional:Dunning, T. (1993). Accurate Methods for the Statistics of Surprise and Coincidence.

*Computational Linguistics*,*19*, 61–74.- Slides
**Rcode for Week 2**

- N-Gram generative language model.
- Slides
- [SLP], chapter 4, http://web.stanford.edu/~jurafsky/slp3/4.pdf
- R-packages:
**ngram**,**textcat**

- Part-of-Speech Tagging.
- Slides
- [SLP], chapter 10, http://web.stanford.edu/~jurafsky/slp3/10.pdf
- R-packages:
**Rcode for Week 3**

- Named Entity Recognition
- Slides
- Homework 2 , Getting started R-script prepare-hw2.R, Presidential Debates Rdata file
- Results for Homework 2

**Part 2: Turn (larger) documents into a vector-space representation and perform (supervised) machine learning for classification type purposes.**

- Vector Space model: vector space representation, bag of words model, measuring distance/ similarity between texts.
- Ideological scaling: introduction to supervised learning concepts; naive LBK ideology scaling, Bayesscore.
- Slides
**Reading**: Laver, M., Benoit, K., & Garry, J. (2003). Extracting Policy Positions from Political Texts Using Words as Data.*The American Political Science Review*,*97*(2), 311–331.- Beauchamp, N. (2010). Text-Based Scaling of Legislatures: A Comparison of Methods with Applications to the US Senate and UK House of Commons.
*Politics*, 1–30. **R code for week 4**

- Classification introduction: Logistic regression, classification error types, measuring accuracy and bias-variance trade-off
- Slides
**Homework 3****Results for Homework 3****Reading****R code for week 5**-
- [SLP], Logistic Regression, Chapter 7, https://web.stanford.edu/~jurafsky/slp3/7.pdf
- [ISLR], Chapter 1-2.2 and Chapter 5, http://www-bcf.usc.edu/~gareth/ISL/

- kNN classification
- Slides
**Reading**- [IIR], Vector space classification, sections on Rocchio and knn, http://nlp.stanford.edu/IR-book/pdf/14vcat.pdf

- Naive Bayes: Bernoulli versus Multi-nomial language models
- Slides (1), Slides (2)
**Reading****R code for week 6**- [SLP], Naive Bayes, Chapter 6, https://web.stanford.edu/~jurafsky/slp3/6.pdf
- [IIR], Naive Bayes, Chapter 13, http://nlp.stanford.edu/IR-book/pdf/13bayes.pdf

**Topic Modelling [moved ahead]**- Slides
- Reading
- Blei (2001), Introduction to Probabilistic Topic Models

**R code for week 7**

- Trees and Forests
- Slides
**Reading**- [ISLR], Chapter 8.

- Support Vector Machines
- Slides
**Reading**- ISLR], Chapter 9

**R code for week 8**

- Some more application examples

**Part 3: In the third part, we will turn to unsupervised learning methods for textual data.**

- Unsupervised learning
- K-Means clustering: k-medoids (PAM), importance of distance measures
- Hierarchical clustering: different linkage

### Presentation schedule

### Data

- Campaign Speeches: Speeches delivered by Trump and Clinton during campaign to similar audiences or on similar issues. CongressionalSpeeches

- Congressional Speeches: Congressional speeches given by (primary) candidates for presidential race 2016 in congress. Note this only includes speeches given by candidates who had some role in congress since 1996 and does thus not include Donald Trump.
- Donald Trump tweets: Some tweets from Donald Trump in the last 3-5 months.