Calculates the word frequency of a text document.