Implementation of TreeMap to find word frequency in a given string.