|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.stats.Counters
public class Counters
Static methods for operating on Counter
s.
All methods that change their arguments change the first argument (only), and have "InPlace" in their name. This class also provides access to Comparators that can be used to sort the keys or entries of this Counter by the counts, in either ascending or descending order.
Method Summary | ||
---|---|---|
static
|
absoluteDifference(Counter<E> c1,
Counter<E> c2)
Returns |c1 - c2|. |
|
static
|
addInPlace(Counter<E> target,
Collection<E> arg)
Sets each value of target to be target[k]+ num-of-times-it-occurs-in-collection if the key is present in the arg collection. |
|
static
|
addInPlace(Counter<E> target,
Counter<E> arg)
Sets each value of target to be target[k]+arg[k] for all keys k in arg. |
|
static
|
addInPlace(Counter<E> target,
Counter<E> arg,
double scale)
Sets each value of target to be target[k]+scale*arg[k] for all keys k in target. |
|
static
|
addInPlace(double[] target,
Counter<E> arg,
Index<E> idx)
Sets each value of double[] target to be target[idx.indexOf(k)]+a.getCount(k) for all keys k in arg |
|
static
|
addInPlace(TwoDimensionalCounter<T1,T2> target,
TwoDimensionalCounter<T1,T2> arg)
For all keys (u,v) in arg, sets target[u,v] to be target[u,v] + arg[u,v] |
|
static
|
addInPlace(TwoDimensionalCounter<T1,T2> target,
TwoDimensionalCounter<T1,T2> arg,
double scale)
For all keys (u,v) in arg, sets target[u,v] to be target[u,v] + scale * arg[u,v] |
|
static
|
argmax(Counter<E> c)
Finds and returns the key in the Counter with the largest count. |
|
static
|
argmin(Counter<E> c)
Finds and returns the key in this Counter with the smallest count. |
|
static
|
asCounter(Collection<E> c)
Takes in a Collection of something and makes a counter, incrementing once for each object in the collection. |
|
static
|
asCounter(FixedPrioritiesPriorityQueue<E> p)
Returns a counter whose keys are the elements in this priority queue, and whose counts are the priorities in this queue. |
|
static
|
asMap(Counter<E> counter)
Returns a map view of the given counter. |
|
static
|
average(Counter<E> c1,
Counter<E> c2)
Returns a new Counter with counts averaged from the two given Counters. |
|
static
|
cosine(Counter<E> c1,
Counter<E> c2)
|
|
static
|
crossEntropy(Counter<E> from,
Counter<E> to)
Note that this implementation doesn't normalize the "from" Counter. |
|
static
|
deleteOutofRange(Counter<E> c,
int top,
int bottom)
Delete 'top' and 'bottom' number of elements from the top and bottom respectively |
|
static
|
deserializeCounter(String filename)
|
|
static
|
diff(Counter<T> goldFeatures,
Counter<T> guessedFeatures)
|
|
static
|
divideInPlace(Counter<E> target,
Counter<E> denominator)
Divides every non-zero count in target by the corresponding value in the denominator Counter. |
|
static
|
divideInPlace(Counter<E> target,
double divisor)
Divides each value in target by the given divisor, in place. |
|
static
|
division(Counter<E> c1,
Counter<E> c2)
Returns c1 divided by c2. |
|
static
|
dotProduct(Counter<E> c1,
Counter<E> c2)
Returns the product of c1 and c2. |
|
static
|
dotProduct(Counter<E> c,
double[] a,
Index<E> idx)
Returns the product of Counter c and double[] a, using Index idx to map entries in C onto a. |
|
static
|
dotProductInPlace(Counter<E> target,
Counter<E> term)
Multiplies every count in target by the corresponding value in the term Counter. |
|
static
|
entropy(Counter<E> c)
Calculates the entropy of the given counter (in bits). |
|
static
|
equals(Counter<E> o1,
Counter<E> o2)
Default equality comparison for two counters potentially backed by alternative implementations. |
|
static
|
exp(Counter<T> c)
|
|
static
|
expInPlace(Counter<T> c)
|
|
static
|
fromMap(Map<E,N> map)
Returns a counter view of the given map. |
|
static
|
fromMap(Map<E,N> map,
Class<N> type)
Returns a counter view of the given map. |
|
static
|
getCopy(Counter<E> originalCounter)
|
|
static
|
getCountCounts(Counter<E> c)
|
|
static
|
hIndex(Counter<E> citationCounts)
Calculate h-Index (Hirsch, 2005) of an author. |
|
static
|
intersection(Counter<E> c1,
Counter<E> c2)
Returns a counter that is the intersection of c1 and c2. |
|
static
|
jaccardCoefficient(Counter<E> c1,
Counter<E> c2)
Returns the Jaccard Coefficient of the two counters. |
|
static
|
jensenShannonDivergence(Counter<E> c1,
Counter<E> c2)
Calculates the Jensen-Shannon divergence between the two counters. |
|
static
|
keysAbove(Counter<E> c,
double countThreshold)
Returns the set of keys whose counts are at or above the given threshold. |
|
static
|
keysAt(Counter<E> c,
double count)
Returns the set of keys that have exactly the given count. |
|
static
|
keysBelow(Counter<E> c,
double countThreshold)
Returns the set of keys whose counts are at or below the given threshold. |
|
static
|
klDivergence(Counter<E> from,
Counter<E> to)
Calculates the KL divergence between the two counters. |
|
static
|
L1Norm(C c)
Return the L1 norm of a counter. |
|
static
|
L2Norm(C c)
Return the l2 norm (Euclidean vector length) of a Counter. |
|
static
|
L2Normalize(C c)
L2 normalize a counter. |
|
static
|
L2NormalizeInPlace(Counter<E> c)
L2 normalize a counter in place. |
|
static
|
linearCombination(Counter<E> c1,
double w1,
Counter<E> c2,
double w2)
Returns a Counter which is a weighted average of c1 and c2. |
|
static
|
load2DCounter(String filename,
Class<T1> t1,
Class<T2> t2)
|
|
static
|
loadCounter(String filename,
Class<E> c)
Loads a Counter from a text file. |
|
static
|
loadIntCounter(String filename,
Class<E> c)
Loads a Counter from a text file. |
|
static
|
logInPlace(Counter<E> target)
|
|
static
|
logNormalizeInPlace(Counter<E> c)
Transform log space values into a probability distribution in place. |
|
static
|
logSum(Counter<E> c)
Returns ArrayMath.logSum of the values in this counter. |
|
static
|
max(Counter<E> c)
Returns the value of the maximum entry in this counter. |
|
static
|
mean(Counter<E> c)
Returns the mean of all the counts (totalCount/size). |
|
static
|
min(Counter<E> c)
Returns the value of the smallest entry in this counter. |
|
static
|
multiplyInPlace(Counter<E> target,
double multiplier)
Multiplies each value in target by the given multiplier, in place. |
|
static
|
normalize(Counter<E> target)
Normalizes the target counter in-place, so the sum of the resulting values equals 1. |
|
static
|
optimizedDotProduct(Counter<E> c1,
Counter<E> c2)
This method does not check entries for NAN or INFINITY values in the doubles returned. |
|
static
|
perturbCounts(C c,
Random random,
double p)
|
|
static
|
pointwiseMutualInformation(Counter<T1> var1Distribution,
Counter<T2> var2Distribution,
Counter<MutablePair<T1,T2>> jointDistribution,
MutablePair<T1,T2> values)
|
|
static
|
pow(Counter<T> c,
double temp)
|
|
static
|
powInPlace(Counter<T> c,
double temp)
|
|
static
|
powNormalized(Counter<E> c,
double temp)
Returns a counter where each element corresponds to the normalized count of the corresponding element in c raised to the given power. |
|
static
|
printCounterComparison(Counter<E> a,
Counter<E> b)
Great for debugging. |
|
static
|
printCounterComparison(Counter<E> a,
Counter<E> b,
PrintStream out)
Great for debugging. |
|
static
|
printCounterSortedByKeys(Counter<E> c)
|
|
static
|
product(Counter<E> c1,
Counter<E> c2)
Returns the product of c1 and c2. |
|
static
|
removeKeys(Counter<E> counter,
Collection<E> removeKeysCollection)
Removes all entries with keys in the given collection |
|
static
|
restrictedArgMax(Counter<E> c,
Collection<E> restriction)
|
|
static
|
retainAbove(Counter<E> counter,
double countThreshold)
Removes all entries with counts below the given threshold, returning the set of removed entries. |
|
static
|
retainBelow(Counter<E> counter,
double countMaxThreshold)
Removes all entries with counts above the given threshold, returning the set of removed entries. |
|
static
|
retainBottom(Counter<E> c,
int num)
Removes all entries from c except for the bottom num |
|
static Set<String> |
retainMatchingKeys(Counter<String> counter,
List<Pattern> matchPatterns)
Removes all entries with keys that does not match one of the given patterns |
|
static
|
retainNonZeros(Counter<E> counter)
Removes all entries with 0 count in the counter, returning the set of removed entries. |
|
static
|
retainTop(Counter<E> c,
int num)
Removes all entries from c except for the top num |
|
static
|
saferL2Norm(C c)
For counters with large # of entries, this scales down each entry in the sum, to prevent an extremely large sum from building up and overwhelming the max double. |
|
static
|
saferL2Normalize(C c)
L2 normalize a counter, using the "safer" L2 normalizer. |
|
static
|
sample(Counter<T> c)
Does not assumes c is normalized. |
|
static
|
sample(Counter<T> c,
Random rand)
Does not assumes c is normalized. |
|
static
|
save2DCounter(TwoDimensionalCounter<T1,T2> tdc,
String filename)
|
|
static
|
saveCounter(Counter<E> c,
OutputStream stream)
Saves a Counter as one key/count pair per line separated by white space to the given OutputStream. |
|
static
|
saveCounter(Counter<E> c,
String filename)
Saves a Counter to a text file. |
|
static
|
scale(C c,
double s)
Returns a new Counter which is scaled by the given scale factor. |
|
static
|
scale(TwoDimensionalCounter<T1,T2> c,
double d)
Creates a new TwoDimensionalCounter where all the counts are scaled by d. |
|
static
|
serializeCounter(Counter<T> c,
String filename)
|
|
static
|
skewDivergence(Counter<E> c1,
Counter<E> c2,
double skew)
Calculates the skew divergence between the two counters. |
|
static
|
subtractInPlace(Counter<E> target,
Counter<E> arg)
Sets each value of target to be target[k]-arg[k] for all keys k in target. |
|
static
|
subtractInPlace(double[] target,
Counter<E> arg,
Index<E> idx)
Sets each value of double[] target to be target[idx.indexOf(k)]-a.getCount(k) for all keys k in arg |
|
static
|
sumEntries(Counter<E> c1,
Collection<E> entries)
|
|
static
|
tfLogScale(C c,
double base)
Returns a new Counter which is the input counter with log tf scaling |
|
static
|
toBiggestValuesFirstString(Counter<E> c)
|
|
static
|
toBiggestValuesFirstString(Counter<E> c,
int k)
|
|
static
|
toBiggestValuesFirstString(Counter<Integer> c,
int k,
Index<T> index)
|
|
static
|
toComparator(Counter<E> counter)
Returns a comparator backed by this counter: two objects are compared by their associated values stored in the counter. |
|
static
|
toComparator(Counter<E> counter,
boolean ascending,
boolean useMagnitude)
Returns a comparator suitable for sorting this Counter's keys or entries by their respective value or magnitude (by absolute value). |
|
static
|
toComparatorDescending(Counter<E> counter)
Returns a comparator backed by this counter: two objects are compared by their associated values stored in the counter. |
|
static
|
toCounter(double[] counts,
Index<T> index)
|
|
static
|
toCounter(Map<Integer,? extends Number> counts,
Index<E> index)
Turns the given map and index into a counter instance. |
|
static
|
toDescendingMagnitudeSortedListWithCounts(Counter<E> c)
|
|
static
|
toPriorityQueue(Counter<E> c)
Returns a PriorityQueue whose elements
are the keys of Counter c,
and the score of each key in c becomes its priority. |
|
static
|
toSortedByKeysString(Counter<T> counter,
String itemFormat,
String joiner,
String wrapperFormat)
Returns a string representation of a Counter, where (key, value) pairs are sorted by key, and formatted as specified. |
|
static
|
toSortedList(Counter<E> c)
A List of the keys in c, sorted from highest count to lowest. |
|
static
|
toSortedListWithCounts(Counter<E> c)
A List of the keys in c, sorted from highest count to lowest, paired with counts |
|
static
|
toSortedString(Counter<T> counter,
int k,
String itemFormat,
String joiner)
Returns a string representation of a Counter, displaying the keys and their counts in decreasing order of count. |
|
static
|
toSortedString(Counter<T> counter,
int k,
String itemFormat,
String joiner,
String wrapperFormat)
Returns a string representation of a Counter, displaying the keys and their counts in decreasing order of count. |
|
static
|
toString(Counter<E> counter,
int maxKeysToPrint)
Returns a string representation which includes no more than the maxKeysToPrint elements with largest counts. |
|
static
|
toString(Counter<E> counter,
NumberFormat nf)
|
|
static
|
toString(Counter<E> counter,
NumberFormat nf,
String preAppend,
String postAppend,
String keyValSeparator,
String itemSeparator)
Pretty print a Counter. |
|
static
|
toVerticalString(Counter<E> c)
|
|
static
|
toVerticalString(Counter<E> c,
int k)
|
|
static
|
toVerticalString(Counter<E> c,
int k,
String fmt)
|
|
static
|
toVerticalString(Counter<E> c,
int k,
String fmt,
boolean swap)
Returns a String representation of the k keys
with the largest counts in the given Counter , using the given
format string. |
|
static
|
toVerticalString(Counter<E> c,
String fmt)
|
|
static
|
transform(Counter<T1> c,
Function<T1,T2> f)
Returns the counter with keys modified according to function F. |
|
static
|
union(C c1,
C c2)
Returns a Counter that is the union of the two Counters passed in (counts are added). |
|
static
|
unmodifiableCounter(Counter<T> counter)
Returns unmodifiable view of the counter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <E> double logSum(Counter<E> c)
c
- Argument counter (which is not modified)
public static <E> void logNormalizeInPlace(Counter<E> c)
c
- The Counter to log normalize in placepublic static <E> double max(Counter<E> c)
c
- The Counter to find the max of
public static <E> Counter<E> asCounter(Collection<E> c)
c
- The Collection to turn into a counter
public static <E> double min(Counter<E> c)
c
- The Counter (not modified)
public static <E> E argmax(Counter<E> c)
c
- The Counter
public static <E> E argmin(Counter<E> c)
c
- The Counter
public static <E> double mean(Counter<E> c)
c
- The Counter to find the mean of.
public static <E> void addInPlace(Counter<E> target, Counter<E> arg, double scale)
target
- A Counter that is modifiedarg
- The Counter whose contents are added to targetscale
- How the arg Counter is scaled before being addedpublic static <E> void addInPlace(Counter<E> target, Counter<E> arg)
public static <E> void addInPlace(double[] target, Counter<E> arg, Index<E> idx)
public static <T1,T2> void addInPlace(TwoDimensionalCounter<T1,T2> target, TwoDimensionalCounter<T1,T2> arg, double scale)
T1
- T2
- public static <T1,T2> void addInPlace(TwoDimensionalCounter<T1,T2> target, TwoDimensionalCounter<T1,T2> arg)
T1
- T2
- public static <E> void addInPlace(Counter<E> target, Collection<E> arg)
public static <E> void subtractInPlace(Counter<E> target, Counter<E> arg)
public static <E> void subtractInPlace(double[] target, Counter<E> arg, Index<E> idx)
public static <E> void divideInPlace(Counter<E> target, Counter<E> denominator)
public static <E> void dotProductInPlace(Counter<E> target, Counter<E> term)
public static <E> Counter<E> divideInPlace(Counter<E> target, double divisor)
target
- The values in this Counter will be changed throught by
the multiplierdivisor
- The number by which to change each number in the
Counter
public static <E> Counter<E> multiplyInPlace(Counter<E> target, double multiplier)
target
- The values in this Counter will be changed throught by
the multipliermultiplier
- The number by which to change each number in the
Counterpublic static <E> void normalize(Counter<E> target)
E
- public static <E> void logInPlace(Counter<E> target)
public static <E> List<E> deleteOutofRange(Counter<E> c, int top, int bottom)
public static <E> void retainTop(Counter<E> c, int num)
num
public static <E> void retainBottom(Counter<E> c, int num)
num
public static <E> Set<E> retainNonZeros(Counter<E> counter)
public static <E> Set<E> retainAbove(Counter<E> counter, double countThreshold)
counter
- The counter.countThreshold
- The minimum count for an entry to be kept. Entries
(strictly) less than this threshold are discarded.
public static <E> Set<E> retainBelow(Counter<E> counter, double countMaxThreshold)
counter
- The counter.countMaxThreshold
- The maximum count for an entry to be kept. Entries
(strictly) more than this threshold are discarded.
public static Set<String> retainMatchingKeys(Counter<String> counter, List<Pattern> matchPatterns)
counter
- The counter.matchPatterns
- pattern for key to match
public static <E> void removeKeys(Counter<E> counter, Collection<E> removeKeysCollection)
E
- counter
- removeKeysCollection
- public static <E> Set<E> keysAbove(Counter<E> c, double countThreshold)
c
- The Counter to examinecountThreshold
- Items equal to or above this number are kept
public static <E> Set<E> keysBelow(Counter<E> c, double countThreshold)
public static <E> Set<E> keysAt(Counter<E> c, double count)
public static <T1,T2> Counter<T2> transform(Counter<T1> c, Function<T1,T2> f)
public static <E> Comparator<E> toComparator(Counter<E> counter)
counter
- The Counter whose values are used for ordering the keys
public static <E> Comparator<E> toComparatorDescending(Counter<E> counter)
counter
- The Counter whose values are used for ordering the keys
public static <E> Comparator<E> toComparator(Counter<E> counter, boolean ascending, boolean useMagnitude)
Counter c = new Counter(); // add to the counter... List biggestKeys = new ArrayList(c.keySet()); Collections.sort(biggestAbsKeys, Counters.comparator(c, false, true)); List smallestEntries = new ArrayList(c.entrySet()); Collections.sort(smallestEntries, Counters.comparator(c, true, false));
public static <E> List<E> toSortedList(Counter<E> c)
public static <E> List<MutablePair<E,Double>> toDescendingMagnitudeSortedListWithCounts(Counter<E> c)
public static <E> List<MutablePair<E,Double>> toSortedListWithCounts(Counter<E> c)
public static <E> PriorityQueue<E> toPriorityQueue(Counter<E> c)
PriorityQueue
whose elements
are the keys of Counter c,
and the score of each key in c becomes its priority.
c
- Input Counter
public static <E,C extends Counter<E>> C union(C c1, C c2)
public static <E> Counter<E> intersection(Counter<E> c1, Counter<E> c2)
public static <E> double jaccardCoefficient(Counter<E> c1, Counter<E> c2)
public static <E> Counter<E> product(Counter<E> c1, Counter<E> c2)
public static <E> double dotProduct(Counter<E> c1, Counter<E> c2)
public static <E> double dotProduct(Counter<E> c, double[] a, Index<E> idx)
public static <E> double sumEntries(Counter<E> c1, Collection<E> entries)
public static <E> double optimizedDotProduct(Counter<E> c1, Counter<E> c2)
E
- c1
- c2
-
public static <E> Counter<E> absoluteDifference(Counter<E> c1, Counter<E> c2)
public static <E> Counter<E> division(Counter<E> c1, Counter<E> c2)
public static <E> double entropy(Counter<E> c)
public static <E> double crossEntropy(Counter<E> from, Counter<E> to)
public static <E> double klDivergence(Counter<E> from, Counter<E> to)
public static <E> double jensenShannonDivergence(Counter<E> c1, Counter<E> c2)
public static <E> double skewDivergence(Counter<E> c1, Counter<E> c2, double skew)
public static <E,C extends Counter<E>> double L2Norm(C c)
c
- The Counter
public static <E,C extends Counter<E>> double L1Norm(C c)
c
- The Counter
public static <E,C extends Counter<E>> C L2Normalize(C c)
c
- The Counter
to be L2 normalized. This counter is
not modified.
public static <E,C extends Counter<E>> Counter<E> L2NormalizeInPlace(Counter<E> c)
c
- The Counter
to be L2 normalized. This counter is modified
public static <E,C extends Counter<E>> double saferL2Norm(C c)
E
- C
- public static <E,C extends Counter<E>> C saferL2Normalize(C c)
c
- The Counter
to be L2 normalized. This counter is
not modified.
public static <E> double cosine(Counter<E> c1, Counter<E> c2)
public static <E> Counter<E> average(Counter<E> c1, Counter<E> c2)
public static <E> Counter<E> linearCombination(Counter<E> c1, double w1, Counter<E> c2, double w2)
public static <T1,T2> double pointwiseMutualInformation(Counter<T1> var1Distribution, Counter<T2> var2Distribution, Counter<MutablePair<T1,T2>> jointDistribution, MutablePair<T1,T2> values)
public static <E> int hIndex(Counter<E> citationCounts)
citationCounts
- Citation counts for each of the articles written by the
author. The keys can be anything, but the values should
be integers.
public static <E,C extends Counter<E>> C perturbCounts(C c, Random random, double p)
public static <E> void printCounterComparison(Counter<E> a, Counter<E> b)
public static <E> void printCounterComparison(Counter<E> a, Counter<E> b, PrintStream out)
public static <E> Counter<Double> getCountCounts(Counter<E> c)
public static <E,C extends Counter<E>> C scale(C c, double s)
c
- The counter to scale. It is not changeds
- The constant to scale the counter by
public static <E,C extends Counter<E>> C tfLogScale(C c, double base)
c
- The counter to scale. It is not changedbase
- The base of the logarithm used for tf scaling by 1 + log tf
public static <E extends Comparable<E>> void printCounterSortedByKeys(Counter<E> c)
public static <E> ClassicCounter<E> loadCounter(String filename, Class<E> c) throws RuntimeException
filename
- the path to the file to load the Counter fromc
- the Class to instantiate each member of the set. Must have a String constructor.
RuntimeException
public static <E> IntCounter<E> loadIntCounter(String filename, Class<E> c) throws Exception
filename
- the path to the file to load the Counter fromc
- the Class to instantiate each member of the set. Must have a String constructor.
Exception
public static <E> void saveCounter(Counter<E> c, OutputStream stream)
public static <E> void saveCounter(Counter<E> c, String filename) throws IOException
IOException
public static <T1,T2> TwoDimensionalCounter<T1,T2> load2DCounter(String filename, Class<T1> t1, Class<T2> t2) throws RuntimeException
RuntimeException
public static <T1,T2> void save2DCounter(TwoDimensionalCounter<T1,T2> tdc, String filename) throws IOException
IOException
public static <T> void serializeCounter(Counter<T> c, String filename) throws IOException
IOException
public static <T> ClassicCounter<T> deserializeCounter(String filename) throws Exception
Exception
public static <T> String toSortedString(Counter<T> counter, int k, String itemFormat, String joiner, String wrapperFormat)
counter
- A Counter.k
- The number of keys to include. Use Integer.MAX_VALUE to
include all keys.itemFormat
- The format string for key/count pairs, where the key is
first and the value is second. To display the value first,
use argument indices, e.g. "%2$f %1$s".joiner
- The string used between pairs of key/value strings.wrapperFormat
- The format string for wrapping text around the joined items,
where the joined item string value is "%s".
public static <T> String toSortedString(Counter<T> counter, int k, String itemFormat, String joiner)
counter
- A Counter.k
- The number of keys to include. Use Integer.MAX_VALUE to
include all keys.itemFormat
- The format string for key/count pairs, where the key is
first and the value is second. To display the value first,
use argument indices, e.g. "%2$f %1$s".joiner
- The string used between pairs of key/value strings.
public static <T extends Comparable<T>> String toSortedByKeysString(Counter<T> counter, String itemFormat, String joiner, String wrapperFormat)
counter
- The Counter.itemFormat
- The format string for key/count pairs, where the key is
first and the value is second. To display the value first,
use argument indices, e.g. "%2$f %1$s".joiner
- The string used between pairs of key/value strings.wrapperFormat
- The format string for wrapping text around the joined items,
where the joined item string value is "%s".
public static <E> String toString(Counter<E> counter, int maxKeysToPrint)
counter
- The CountermaxKeysToPrint
- Max keys to print
public static <E> String toString(Counter<E> counter, NumberFormat nf)
public static <E> String toString(Counter<E> counter, NumberFormat nf, String preAppend, String postAppend, String keyValSeparator, String itemSeparator)
public static <E> String toBiggestValuesFirstString(Counter<E> c)
public static <E> String toBiggestValuesFirstString(Counter<E> c, int k)
public static <T> String toBiggestValuesFirstString(Counter<Integer> c, int k, Index<T> index)
public static <E> String toVerticalString(Counter<E> c)
public static <E> String toVerticalString(Counter<E> c, int k)
public static <E> String toVerticalString(Counter<E> c, String fmt)
public static <E> String toVerticalString(Counter<E> c, int k, String fmt)
public static <E> String toVerticalString(Counter<E> c, int k, String fmt, boolean swap)
String
representation of the k
keys
with the largest counts in the given Counter
, using the given
format string.
c
- a Counterk
- how many keys to printfmt
- a format string, such as "%.0f\t%s" (do not include final "%n")swap
- whether the count should appear after the keypublic static <E> E restrictedArgMax(Counter<E> c, Collection<E> restriction)
public static <T> Counter<T> toCounter(double[] counts, Index<T> index)
public static <E> Counter<E> toCounter(Map<Integer,? extends Number> counts, Index<E> index)
public static <T1,T2> TwoDimensionalCounter<T1,T2> scale(TwoDimensionalCounter<T1,T2> c, double d)
public static <T> T sample(Counter<T> c, Random rand)
public static <T> T sample(Counter<T> c)
public static <E> Counter<E> powNormalized(Counter<E> c, double temp)
public static <T> Counter<T> pow(Counter<T> c, double temp)
public static <T> void powInPlace(Counter<T> c, double temp)
public static <T> Counter<T> exp(Counter<T> c)
public static <T> void expInPlace(Counter<T> c)
public static <T> Counter<T> diff(Counter<T> goldFeatures, Counter<T> guessedFeatures)
public static <E> boolean equals(Counter<E> o1, Counter<E> o2)
public static <T> Counter<T> unmodifiableCounter(Counter<T> counter)
counter
- The counter
public static <E> Counter<E> asCounter(FixedPrioritiesPriorityQueue<E> p)
public static <E,N extends Number> Counter<E> fromMap(Map<E,N> map)
public static <E,N extends Number> Counter<E> fromMap(Map<E,N> map, Class<N> type)
public static <E> Map<E,Double> asMap(Counter<E> counter)
public static <E> Counter<E> getCopy(Counter<E> originalCounter)
E
- originalCounter
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |