|
|||||||||
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(java.util.Collection<E> l)
|
|
static
|
createCounterFromList(java.util.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
|
exp(Counter<T> c)
|
|
static
|
getCountCounts(GenericCounter<E> c)
|
|
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(java.lang.String filename,
java.lang.Class c)
Loads a Counter from a text file. |
|
static IntCounter |
loadIntCounter(java.lang.String filename,
java.lang.Class c)
Loads a Counter from a text file. |
|
static
|
perturbCounts(GenericCounter<E> c,
java.util.Random random,
double p)
|
|
static
|
pow(Counter<T> c,
double temp)
|
|
static
|
printCounterComparison(GenericCounter<E> a,
GenericCounter<E> b)
Great for debugging. |
|
static
|
printCounterComparison(GenericCounter<E> a,
GenericCounter<E> b,
java.io.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 java.lang.Object |
restrictedArgMax(Counter c,
java.util.Collection restriction)
|
|
static
|
sample(Counter<T> c,
java.util.Random rand)
Assumes c is normalized. |
|
static
|
saveCounter(GenericCounter<E> c,
java.lang.String filename)
Saves a Counter to a text file. |
|
static
|
scale(GenericCounter<E> 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
|
skewDivergence(GenericCounter<E> c1,
GenericCounter<E> c2,
double skew)
Calculates the skew divergence between the two counters. |
|
static java.util.List |
sortedKeys(Counter x)
|
|
static java.lang.String |
toBiggestValuesFirstString(Counter c)
|
|
static java.lang.String |
toBiggestValuesFirstString(Counter c,
int k)
|
|
static
|
toCounter(double[] counts,
Index<T> index)
|
|
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)
A List of the keys in c, sorted from highest count to lowest. |
|
static java.lang.String |
toVerticalString(Counter c)
|
|
static java.lang.String |
toVerticalString(Counter c,
int k)
|
|
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, java.util.Random random, double p)
public static <E> Counter<E> createCounterFromList(java.util.List<E> l)
public static <E> Counter<E> createCounterFromCollection(java.util.Collection<E> l)
public static <E> java.util.List<E> toSortedList(GenericCounter<E> c)
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, java.io.PrintStream out)
a
- b
- public static <E> Counter<java.lang.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(java.lang.String filename, java.lang.Class c) throws java.lang.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.
java.lang.Exception
public static IntCounter loadIntCounter(java.lang.String filename, java.lang.Class c) throws java.lang.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.
java.lang.Exception
public static <E> void saveCounter(GenericCounter<E> c, java.lang.String filename) throws java.io.IOException
c
- filename
-
java.io.IOException
public static java.util.List sortedKeys(Counter x)
public static java.lang.String toBiggestValuesFirstString(Counter c)
public static java.lang.String toBiggestValuesFirstString(Counter c, int k)
public static java.lang.String toVerticalString(Counter c)
public static java.lang.String toVerticalString(Counter c, int k)
public static java.lang.Object restrictedArgMax(Counter c, java.util.Collection restriction)
c
- restriction
-
public static <T> Counter<T> toCounter(double[] counts, Index<T> index)
public static <T1,T2> TwoDimensionalCounter<T1,T2> scale(TwoDimensionalCounter<T1,T2> c, double d)
c
- d
-
public static <T> T sample(Counter<T> c, java.util.Random rand)
c
- rand
-
public static <T> Counter<T> pow(Counter<T> c, double temp)
public static <T> Counter<T> exp(Counter<T> c)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |