package tsp.application; import java.util.*; public class SearchEngine { //... public double getFrequency(String word, Document document){ return document.getFrequency(word); } public double getIDF(String word){ if (!this.inverseIndex.containsKey(word)) return 0; return Math.log(this.nDocuments / this.inverseIndex.get(word).size()); } public double getTFIDF(String word, Document document){ return this.getFrequency(word, document) * this.getIDF(word); } }