Added a term frequency counting function