Added function for calculating word frequency in text