public PairOfIntLong getStats(String term) { int df = -1; long cf = -1; PairOfIntLong p = new PairOfIntLong(); if (frequentTermsDfs != null) { try { df = frequentTermsDfs.get(term); LOGGER.info("[cached] df of " + term + ": " + df); if (frequentTermsCfs != null) { try { cf = frequentTermsCfs.get(term); LOGGER.info("[cached] cf of " + term + ": " + cf); p.set(df, cf); return p; } catch (NoSuchElementException e) { } } } catch (NoSuchElementException e) { } } int index = prefixSet.getId(term); LOGGER.info("index of " + term + ": " + index); if (index < 0) return null; p.set(dfs[index], cfs[index]); return p; }
private void loadFrequentCfMap(int n) { if (frequentTermsCfs != null) return; frequentTermsCfs = new HMapKL<String>(); if (cfs.length < n) n = cfs.length; for (int id = 1; id <= n; id++) { frequentTermsCfs.put(prefixSet.getTerm(idToTerm[id - 1]), cfs[idToTerm[id - 1]]); } }
public long getCF(String term) { // if(cfs == null) // throw new RuntimeException("CF-Stats must be loaded first!"); if (frequentTermsDfs != null) { try { long cf = frequentTermsCfs.get(term); LOGGER.info("[cached] df of " + term + ": " + cf); return cf; } catch (NoSuchElementException e) { } } int index = prefixSet.getId(term); LOGGER.info("index of " + term + ": " + index); if (index < 0) return -1; return cfs[index]; }