|
|||||||||
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.
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 Counter |
deserializeCounter(String filename)
|
|
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(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
|
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,
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
|
restrictedArgMax(Counter<E> c,
Collection<E> restriction)
|
|
static
|
sample(Counter<T> c,
Random rand)
Assumes c is normalized. |
|
static
|
saveCounter(GenericCounter<E> c,
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 void |
serializeCounter(GenericCounter c,
String filename)
|
|
static
|
skewDivergence(GenericCounter<E> c1,
GenericCounter<E> c2,
double skew)
Calculates the skew divergence between the two counters. |
|
static
|
sortedKeys(Counter<E> x)
|
|
static
|
toBiggestValuesFirstString(Counter<E> c)
|
|
static
|
toBiggestValuesFirstString(Counter<E> 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 String |
toVerticalString(Counter c)
|
|
static 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 |
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)
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 void serializeCounter(GenericCounter c, String filename) throws IOException
IOException
public static Counter deserializeCounter(String filename) throws Exception
Exception
public static <E> List<E> sortedKeys(Counter<E> x)
public static <E> String toBiggestValuesFirstString(Counter<E> c)
public static <E> String toBiggestValuesFirstString(Counter<E> c, int k)
public static String toVerticalString(Counter c)
public static String toVerticalString(Counter c, int k)
public static <E> Object restrictedArgMax(Counter<E> c, Collection<E> 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, 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 |