Modified WordWeighting function to eliminate the parsing error