Problem 2
In this particular project, we are going to work on the inaugural corpora from the
nltk in Python. We will be looking at the following speeches of the Presidents of
the United States of America:
1. President Franklin D. Roosevelt in 1941
2. President John F. Kennedy in 1961
3. President Richard Nixon in 1973
2.1 Find the number of characters, words, and sentences for the
mentioned documents.
‘+ Number of Character:
Characters count for 1941-Roosevelt speech is
Characters count for 1961-Kennedy speech is
Characters count for 1973-Nixon speech is = 9991
+ Number of Words:
Words count for 1941-Roosevelt speech is = 1536
Words count for 1961-Kennedy speech is = 1546
Words count for 1973-Nixon speech is = 2028
+ Number of Sentences:
Sentences count for 1941-Roosevelt speech is
Sentences count for 1961-Kennedy speech is = 52
Sentences count for 1973-Nixon speech is = 692.2 Remove all the stopwords from all three speeches.
def remove_stopwords(array stop)
filtered = []
for ain array:
al = allower()
if al not in stopw and al="
filtered.append(al)
return filtered
stopw = set(stopwords.words(english’)list(string.punctuation))
Rwords = remove_stopwords(R_wordsstopw)
Kwords = remove_stopwords(K_words stopw)
Nwords = remove_stopwords(N_wordsstopw)
2.3 Which word occurs the most number of times in his inaugural
address for each president? Mention the top three words. (after
removing the stopwords).
} Top 3 words:
Top three words of Roosevelt: [('nation', 12), (‘know', 10), (‘spirit!, 9)]
Top three words of Kennedy: [(let’, 16), (‘us', 12), (‘world!, 8)]
Top three words of Nixon: [(‘us', 26), (‘let, 22), america’, 21)]2.4 Plot the word cloud of each of the speeches of the variable. (after
removing the stopwords.
+ Word Cloud for 1941-Roosevelt ‘his
government
+ Word Cloud for 1961-Kennedy speech is
PP agest
ue a+ Word counts for 1973-Nixon speech is
responsibility
eee broads: Vig
ea I er
i e<
Breath jcthers:
vreie
§ maker.§ Uo Yive™