text_plain_output_1.png
from collections import Counter

import nltk

import os

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

file_dict_list = []
for filename in dirs:
    file_dict = {}
    job_word_count = count_words('job', filename) + count_words('jobs', filename)
    file_dict['year'] = int(filename[-8:-4])
    file_dict['job_word_count'] = job_word_count
    file_dict_list.append(file_dict)
print(file_dict_list)