/* * 過濾頻率過低字詞 */ public static TreeMap<String, Double> QueryExpansion( Map<String, Double> revisedQuery, double minWeight, int maxTermCount) { SortedSet<Entry<String, Double>> sortedTerms = SetUtility.entriesSortedByValuesDesc(revisedQuery); TreeMap<String, Double> result = new TreeMap<String, Double>(); String term = null; Double weight = 0.0; for (Entry<String, Double> entry : sortedTerms) { term = entry.getKey(); weight = entry.getValue(); if (result.size() < maxTermCount && weight >= minWeight) { result.put(term, weight); } } return result; }
public static void main(String[] args) { Rocchio_termfiltered ro = new Rocchio_termfiltered("302", 20, 0.6, 0); System.out.println(SetUtility.entriesSortedByValuesDesc(ro.getRevisedQuery())); }