@Override public void reduce(Text key, Iterable<HMapStIW> values, Context context) throws IOException, InterruptedException { Iterator<HMapStIW> iter = values.iterator(); HMapStIW map = new HMapStIW(); while (iter.hasNext()) { map.plus(iter.next()); } HMapStFW writeMap = new HMapStFW(); double pmi = 0.0; for (MapKI.Entry<String> entry : map.entrySet()) { String k = entry.getKey(); if (map.get(k) >= 10) { if (wordCounts.containsKey(key.toString()) && wordCounts.containsKey(k)) { int px = wordCounts.get(key.toString()); int py = wordCounts.get(k); pmi = Math.log10(((double) (map.get(k)) / (px * py)) * wordCounts.get("numLines*")); writeMap.put(k, (float) pmi); } } } if (writeMap.size() > 0) { context.write(key, writeMap); } }
@Override public void reduce(Text key, Iterable<HMapStIW> values, Context context) throws IOException, InterruptedException { Iterator<HMapStIW> iter = values.iterator(); HMapStIW map = new HMapStIW(); while (iter.hasNext()) { map.plus(iter.next()); } context.write(key, map); }