/** * Sets the current count for each of the given keys. This will wipe out * any existing counts for these keys. * <p> * To add to the counts of a collection of objects instead of replacing them, * use {@link #incrementCounts(Collection,int)}. */ public void setCounts(Collection<E> keys, int count) { for (E key : keys) { setCount(key, count); } }
public void setCount(E key, double value) { setCount(key, (int)value); }
public void setCount(E key, String s) { setCount(key, Integer.parseInt(s)); }
public IntCounter<K1> totalCounts() { IntCounter<K1> tc = new IntCounter<>(); for (K1 k1:map.keySet()) { tc.setCount(k1, map.get(k1).totalCount()); } return tc; }
/** * Converts a counter to ranks; ranks start from 0 * * @return A counter where the count is the rank in the original counter */ public static <E> IntCounter<E> toRankCounter(Counter<E> c) { IntCounter<E> rankCounter = new IntCounter<>(); List<E> sortedList = toSortedList(c); for (int i = 0; i < sortedList.size(); i++) { rankCounter.setCount(sortedList.get(i), i); } return rankCounter; }
/** */ public void setCount(K1 o1, K2 o2, int count) { IntCounter<K2> c = getCounter(o1); int oldCount = getCount(o1, o2); total -= oldCount; c.setCount(o2, count); total += count; }
/** * Splits the state counts. Root states and the boundary tag do not * get their counts increased, and all others are doubled. Betas * and transition weights are handled later. */ private void splitStateCounts() { // double the count of states... IntCounter<String> newStateSplitCounts = new IntCounter<>(); newStateSplitCounts.addAll(stateSplitCounts); newStateSplitCounts.addAll(stateSplitCounts); // root states should only have 1 for (String root : startSymbols) { if (newStateSplitCounts.getCount(root) > 1) { newStateSplitCounts.setCount(root, 1); } } if (newStateSplitCounts.getCount(Lexicon.BOUNDARY_TAG) > 1) { newStateSplitCounts.setCount(Lexicon.BOUNDARY_TAG, 1); } stateSplitCounts = newStateSplitCounts; }
public IntCounter<Pair<K1, K2>> flatten() { IntCounter<Pair<K1, K2>> result = new IntCounter<>(); result.setDefaultReturnValue(defaultValue); for (K1 key1 : firstKeySet()) { IntCounter<K2> inner = getCounter(key1); for (K2 key2 : inner.keySet()) { result.setCount(new Pair<>(key1, key2), inner.getIntCount(key2)); } } return result; }
/** * Sets the current count for each of the given keys. This will wipe out * any existing counts for these keys. * <p> * To add to the counts of a collection of objects instead of replacing them, * use {@link #incrementCounts(Collection,int)}. */ public void setCounts(Collection<E> keys, int count) { for (E key : keys) { setCount(key, count); } }
/** * Sets the current count for each of the given keys. This will wipe out * any existing counts for these keys. * <p> * To add to the counts of a collection of objects instead of replacing them, * use {@link #incrementCounts(Collection,int)}. */ public void setCounts(Collection<E> keys, int count) { for (E key : keys) { setCount(key, count); } }
public void setCount(E key, double value) { setCount(key, (int)value); }
/** * Sets the current count for each of the given keys. This will wipe out * any existing counts for these keys. * <p/> * To add to the counts of a collection of objects instead of replacing them, * use {@link #incrementCounts(Collection,int)}. */ public void setCounts(Collection<E> keys, int count) { for (E key : keys) { setCount(key, count); } }
public IntCounter<K1> totalCounts() { IntCounter<K1> tc = new IntCounter<>(); for (K1 k1:map.keySet()) { tc.setCount(k1, map.get(k1).totalCount()); } return tc; }
public IntCounter<K1> totalCounts() { IntCounter<K1> tc = new IntCounter<K1>(); for (K1 k1:map.keySet()) { tc.setCount(k1, map.get(k1).totalCount()); } return tc; }
public IntCounter<K1> totalCounts() { IntCounter<K1> tc = new IntCounter<>(); for (K1 k1:map.keySet()) { tc.setCount(k1, map.get(k1).totalCount()); } return tc; }
/** */ public void setCount(K1 o1, K2 o2, int count) { IntCounter<K2> c = getCounter(o1); int oldCount = getCount(o1, o2); total -= oldCount; c.setCount(o2, count); total += count; }
/** */ public void setCount(K1 o1, K2 o2, int count) { IntCounter<K2> c = getCounter(o1); int oldCount = getCount(o1, o2); total -= oldCount; c.setCount(o2, count); total += count; }
public IntCounter<Pair<K1, K2>> flatten() { IntCounter<Pair<K1, K2>> result = new IntCounter<>(); result.setDefaultReturnValue(defaultValue); for (K1 key1 : firstKeySet()) { IntCounter<K2> inner = getCounter(key1); for (K2 key2 : inner.keySet()) { result.setCount(new Pair<>(key1, key2), inner.getIntCount(key2)); } } return result; }
public IntCounter<Pair<K1, K2>> flatten() { IntCounter<Pair<K1, K2>> result = new IntCounter<Pair<K1, K2>>(); result.setDefaultReturnValue(defaultValue); for (K1 key1 : firstKeySet()) { IntCounter<K2> inner = getCounter(key1); for (K2 key2 : inner.keySet()) { result.setCount(new Pair<K1, K2>(key1, key2), inner.getIntCount(key2)); } } return result; }
public IntCounter<Pair<K1, K2>> flatten() { IntCounter<Pair<K1, K2>> result = new IntCounter<>(); result.setDefaultReturnValue(defaultValue); for (K1 key1 : firstKeySet()) { IntCounter<K2> inner = getCounter(key1); for (K2 key2 : inner.keySet()) { result.setCount(new Pair<>(key1, key2), inner.getIntCount(key2)); } } return result; }