prob4: computing term frequency