You’re performing an integer division and then type casting:
tf = (double) ( word.getValue() / noOfTerms );
^-----integer division----^
Type cast one of the elements in the division to convert into a floating point division:
tf = ((double)word.getValue()) / noOfTerms;