text_html_output_1.png
from collections import Counter

import nltk

import os

import string

path = '../input/state-of-the-union-corpus-1989-2017'
dirs = os.listdir(path)

def count_words(word, filename):
    file = open(path + '/' + filename, encoding='utf8')
    text = file.read().lower()
    words = nltk.word_tokenize(text)
    word_counter = Counter(words)
    word_count = word_counter[word]
    return word_count

bush_2003_filename = 'Bush_2003.txt'
bush_2003_file = open(path + '/' + 'Bush_2003.txt', encoding='utf8')
bush_2003_text = bush_2003_file.read().lower()
bush_2003_words = nltk.word_tokenize(bush_2003_text)
useless_words = nltk.corpus.stopwords.words('english') + list(string.punctuation) + ['will', 'americans', 'america', 'american', '—', "'s"]
bush_2003_words_filtered = [word for word in bush_2003_words if word not in useless_words]
bush_2003_word_counter = Counter(bush_2003_words_filtered)
most_common_words_2003 = bush_2003_word_counter.most_common()
most_common_words_2003