public double probabilityOfNewObject() { return alpha / sampled.totalCount(); }
@Override public void remove(K1 key) { ClassicCounter<K2> counter = map.get(key); if (counter != null) { total -= counter.totalCount(); } map.remove(key); }
public void recomputeTotal(){ total = 0; for(Entry<K1, ClassicCounter<K2>> c: map.entrySet()){ total += c.getValue().totalCount(); } }
/** */ @Override public double totalCount(K1 k1) { ClassicCounter<K2> c = getCounter(k1); return c.totalCount(); }
public double probabilityOf(E object) { if (object == null) { throw new RuntimeException("You cannot ask for the probability of null."); } if (sampled.keySet().contains(object)) { return sampled.getCount(object) / sampled.totalCount(); } else { return 0.0; } }
/** * replace the counter for K1-index o by new counter c */ public ClassicCounter<K2> setCounter(K1 o, Counter<K2> c) { ClassicCounter<K2> old = getCounter(o); total -= old.totalCount(); if (c instanceof ClassicCounter) { map.put(o, (ClassicCounter<K2>) c); } else { map.put(o, new ClassicCounter<>(c)); } total += c.totalCount(); return old; }
/** */ @Override public double getCount(K1 o1, K2 o2) { ClassicCounter<K2> c = getCounter(o1); if (c.totalCount() == 0.0 && !c.keySet().contains(o2)) { return defaultReturnValue(); } return c.getCount(o2); }
List<Pair<List<String>,Double>> answers = new ArrayList<>(); ClassicCounter<List<String>> cntr = nr.get(node); double support = (cntr.totalCount()); for (List<String> key : pr.keySet()) { if (key.get(0).equals(node)) { // only do it if they match ClassicCounter<List<String>> cntr2 = pr.get(key); double support2 = cntr2.totalCount(); double kl = Counters.klDivergence(cntr2, cntr); answers.add(new Pair<>(key, new Double(kl * support2))); ArrayList<Pair<List<String>,Double>> answers = Generics.newArrayList(); ClassicCounter<List<String>> cntr = pr.get(node); double support = (cntr.totalCount()); if (support < SUPPCUTOFF) { continue; double support2 = (cntr2.totalCount()); double kl = Counters.klDivergence(cntr2, cntr); answers.add(new Pair<>(key, new Double(kl * support2)));
String label = (String) o; ClassicCounter cntr = (ClassicCounter) nodeRules.get(label); double support = (cntr.totalCount()); System.out.println("Node " + label + " support is " + support); String sis = (String) o4; ClassicCounter cntr2 = (ClassicCounter) ((HashMap) leftRules.get(label)).get(sis); double support2 = (cntr2.totalCount()); String sis = (String) o3; ClassicCounter cntr2 = (ClassicCounter) ((HashMap) rightRules.get(label)).get(sis); double support2 = (cntr2.totalCount()); double kl = Counters.klDivergence(cntr2, cntr); String annotatedLabel = label + "=r=" + sis;
/** * Returns the counters with keys as the first key and count as the * total count of the inner counter for that key * * @return counter of type K1 */ public Counter<K1> sumInnerCounter() { Counter<K1> summed = new ClassicCounter<>(); for (K1 key : this.firstKeySet()) { summed.incrementCount(key, this.getCounter(key).totalCount()); } return summed; }
pw.println("There are " + singletonChars.size() + " singleton chars out of " + (int) charCounter.totalCount() + " tokens and " + charCounter.size() + " types found in " + counter + " trees."); pw.println("Thus singletonChars comprise " + percent.format(singletonChars.size() / charCounter.totalCount()) + " of tokens and " + percent.format((double) singletonChars.size() / charCounter.size()) + " of types."); pw.println(); pw.println("There are " + singletonWords.size() + " singleton words out of " + (int) wordCounter.totalCount() + " tokens and " + wordCounter.size() + " types."); pw.println("Thus singletonWords comprise " + percent.format(singletonWords.size() / wordCounter.totalCount()) + " of tokens and " + percent.format((double) singletonWords.size() / wordCounter.size()) + " of types."); pw.println(); pw.println("Distribution over singleton word POS:");
ArrayList<Pair<List<String>,Double>> answers = Generics.newArrayList(); ClassicCounter<List<String>> cntr = nodeRules.get(node); double support = (cntr.totalCount()); System.out.println("Node " + node + " support is " + support); for (List<String> key : pRules.keySet()) { if (key.get(0).equals(node)) { // only do it if they match ClassicCounter<List<String>> cntr2 = pRules.get(key); double support2 = (cntr2.totalCount()); double kl = Counters.klDivergence(cntr2, cntr); System.out.println("KL(" + key + "||" + node + ") = " + nf.format(kl) + "\t" + "support(" + key + ") = " + support2); ArrayList<Pair<List<String>, Double>> answers = Generics.newArrayList(); ClassicCounter<List<String>> cntr = pRules.get(node); double support = (cntr.totalCount()); if (support < SUPPCUTOFF) { continue; if (key.get(0).equals(node.get(0)) && key.get(1).equals(node.get(1))) { // only do it if they match ClassicCounter<List<String>> cntr2 = gPRules.get(key); double support2 = (cntr2.totalCount()); double kl = Counters.klDivergence(cntr2, cntr); System.out.println("KL(" + key + "||" + node + ") = " + nf.format(kl) + "\t" + "support(" + key + ") = " + support2);
public void recomputeTotal(){ total = 0; for(Entry<K1, ClassicCounter<K2>> c: map.entrySet()){ total += c.getValue().totalCount(); } }
@Override public void remove(K1 key) { ClassicCounter<K2> counter = map.get(key); if (counter != null) { total -= counter.totalCount(); } map.remove(key); }
@Override public void remove(K1 key) { ClassicCounter<K2> counter = map.get(key); if (counter != null) { total -= counter.totalCount(); } map.remove(key); }
public void remove(K1 key) { ClassicCounter<K2> counter = map.get(key); if (counter != null) { total -= counter.totalCount(); } map.remove(key); }
/** */ @Override public double totalCount(K1 k1) { ClassicCounter<K2> c = getCounter(k1); return c.totalCount(); }
/** */ public double totalCount(K1 k1) { ClassicCounter<K2> c = getCounter(k1); return c.totalCount(); }
/** */ public double getCount(K1 o1, K2 o2) { ClassicCounter<K2> c = getCounter(o1); if (c.totalCount() == 0.0 && !c.keySet().contains(o2)) { return defaultReturnValue(); } return c.getCount(o2); }
/** */ @Override public double getCount(K1 o1, K2 o2) { ClassicCounter<K2> c = getCounter(o1); if (c.totalCount() == 0.0 && !c.keySet().contains(o2)) { return defaultReturnValue(); } return c.getCount(o2); }