Compute term frequency