Lecture 9 - Exercise¶

In [ ]:
import numpy as np
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import nltk
import spacy

Run this - it may take a minute:

In [ ]:
nlp = spacy.load('en_core_web_sm')
nltk.download('inaugural')
speeches = [nlp(nltk.corpus.inaugural.raw(f)) for f in nltk.corpus.inaugural.fileids()]

speeches is now a list of 60 spacy NLP objects (i.e., they've been analyzed by spacy)

Task 1: Plot the number of tokens in a speech over time.

In [ ]:
 

Task 2: Make a plot showing the fraction of tokens in a speech that are adverbs (pos_ is ADV) as a function of time.

In [ ]:
 

Task 3: Do something else interesting!

In [ ]: