|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.stats.Counters<E>
public class Counters<E>
Static methods for operating on Counter
s.
Constructor Summary | |
---|---|
Counters()
|
Method Summary | ||
---|---|---|
static
|
absoluteDifference(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns |c1 - c2|. |
|
static
|
average(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns a new Counter with counts averaged from the two given Counters. |
|
static
|
cosine(GenericCounter<E> c1,
GenericCounter<E> c2)
|
|
static
|
createCounterFromCollection(Collection<E> l)
|
|
static
|
createCounterFromList(List<E> l)
|
|
static
|
crossEntropy(GenericCounter<E> from,
Counter<E> to)
Note that this implementation doesn't normalize the "from" Counter. |
|
static
|
crossEntropy(GenericCounter<E> from,
GenericCounter<E> to)
Note that this implementation doesn't normalize the "from" Counter. |
|
static
|
division(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns c1 divided by c2. |
|
static
|
dotProduct(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns the product of c1 and c2. |
|
static
|
entropy(GenericCounter<E> c)
Calculates the entropy of the given counter (in bits). |
|
static
|
getCountCounts(GenericCounter<E> c)
|
|
static
|
incrementNonzero(Counter<E> c1,
Counter<E> c2)
Increments counts on all those keys in c1 for which c2 has a nonzero count (i.e., for which c2 has in its keyset). |
|
static
|
intersection(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns a counter that is the intersection of c1 and c2. |
|
static
|
jaccardCoefficient(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns the Jaccard Coefficient of the two counters. |
|
static
|
jensenShannonDivergence(GenericCounter<E> c1,
GenericCounter<E> c2)
Calculates the Jensen-Shannon divergence between the two counters. |
|
static
|
klDivergence(GenericCounter<E> from,
GenericCounter<E> to)
Calculates the KL divergence between the two counters. |
|
static
|
L2Normalize(GenericCounter<E> c)
L2 normalize a counter. |
|
static
|
linearCombination(GenericCounter<E> c1,
double w1,
GenericCounter<E> c2,
double w2)
Returns a Counter which is a weighted average of c1 and c2. |
|
static
|
loadCounter(String filename,
Class c)
Loads a Counter from a text file. |
|
static IntCounter |
loadIntCounter(String filename,
Class c)
Loads a Counter from a text file. |
|
static
|
perturbCounts(GenericCounter<E> c,
Random random,
double p)
|
|
static
|
printCounterComparison(GenericCounter<E> a,
GenericCounter<E> b)
Great for debugging. |
|
static
|
printCounterComparison(GenericCounter<E> a,
GenericCounter<E> b,
PrintStream out)
Great for debugging. |
|
static
|
printCounterSortedByKeys(GenericCounter<E> c)
|
|
static
|
product(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns the product of c1 and c2. |
|
static
|
saveCounter(GenericCounter<E> c,
String filename)
Saves a Counter to a text file. |
|
static
|
scale(GenericCounter<E> c,
double s)
Scales each element in the Counter by the given scale factor. |
|
static
|
skewDivergence(GenericCounter<E> c1,
GenericCounter<E> c2,
double skew)
Calculates the skew divergence between the two counters. |
|
static List |
sortedKeys(Counter x)
|
|
static String |
toBiggestValuesFirstString(Counter c)
|
|
static String |
toBiggestValuesFirstString(Counter c,
int k)
|
|
static
|
toPriorityQueue(GenericCounter<E> c)
Returns a PriorityQueue of the c where the score of the object is its priority. |
|
static
|
toSortedList(GenericCounter<E> c)
|
|
static
|
union(GenericCounter<E> c1,
GenericCounter<E> c2)
Returns a Counter that is the union of the two Counters passed in (counts are added). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Counters()
Method Detail |
---|
public static <E> Counter<E> union(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> Counter<E> intersection(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> double jaccardCoefficient(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> Counter<E> product(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> double dotProduct(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> Counter<E> absoluteDifference(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> Counter<E> division(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> double entropy(GenericCounter<E> c)
public static <E> double crossEntropy(GenericCounter<E> from, GenericCounter<E> to)
public static <E> double crossEntropy(GenericCounter<E> from, Counter<E> to)
public static <E> double klDivergence(GenericCounter<E> from, GenericCounter<E> to)
from
- to
-
public static <E> double jensenShannonDivergence(GenericCounter<E> c1, GenericCounter<E> c2)
c1
- c2
-
public static <E> double skewDivergence(GenericCounter<E> c1, GenericCounter<E> c2, double skew)
c1
- c2
- skew
-
public static <E> Counter<E> L2Normalize(GenericCounter<E> c)
c
- the GenericCounter
to be L2 normalized.public static <E> double cosine(GenericCounter<E> c1, GenericCounter<E> c2)
public static <E> Counter<E> average(GenericCounter<E> c1, GenericCounter<E> c2)
public static <E> Counter<E> linearCombination(GenericCounter<E> c1, double w1, GenericCounter<E> c2, double w2)
public static <E> Counter<E> perturbCounts(GenericCounter<E> c, Random random, double p)
public static <E> Counter<E> createCounterFromList(List<E> l)
public static <E> Counter<E> createCounterFromCollection(Collection<E> l)
public static <E> List<E> toSortedList(GenericCounter<E> c)
public static <E> PriorityQueue toPriorityQueue(GenericCounter<E> c)
PriorityQueue
of the c where the score of the object is its priority.
public static <E> void printCounterComparison(GenericCounter<E> a, GenericCounter<E> b)
a
- b
- public static <E> void printCounterComparison(GenericCounter<E> a, GenericCounter<E> b, PrintStream out)
a
- b
- public static <E> Counter<Double> getCountCounts(GenericCounter<E> c)
public static <E> Counter<E> scale(GenericCounter<E> c, double s)
public static <E> void printCounterSortedByKeys(GenericCounter<E> c)
public static <E> Counter<E> loadCounter(String filename, Class 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 IntCounter loadIntCounter(String filename, Class 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(GenericCounter<E> c, String filename) throws IOException
c
- filename
-
IOException
public static <E> void incrementNonzero(Counter<E> c1, Counter<E> c2)
public static List sortedKeys(Counter x)
public static String toBiggestValuesFirstString(Counter c)
public static String toBiggestValuesFirstString(Counter c, int k)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |