Table of Contents

8th programming lab

Spam continued

live programming session

word counter

How to implement a word counter - function compute_word_frequencies

Imagine a text file example.txt that contains:

one
one two
one two three
one two three four

>>> from texttools import compute_word_frequencies
>>> compute_word_frequencies('example.txt')
{'one': 4, 'two': 3, 'three': 2, 'four': 1}