|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.Counters
public class Counters
Static methods for operating on Counter
s.
Constructor Summary | |
---|---|
Counters()
|
Method Summary | |
---|---|
static Counter |
average(GenericCounter c1,
GenericCounter c2)
Returns a new Counter with counts averaged from the two given Counters. |
static double |
cosine(GenericCounter c1,
GenericCounter c2)
|
static Counter |
createCounterFromList(java.util.List l)
|
static double |
crossEntropy(GenericCounter from,
Distribution to,
Counter justification)
Note that this implementation doesn't normalize the "from" Counter. |
static double |
crossEntropy(GenericCounter from,
GenericCounter to)
Note that this implementation doesn't normalize the "from" Counter. |
static Counter |
division(GenericCounter c1,
GenericCounter c2)
Returns c1 divided by c2. |
static double |
entropy(GenericCounter c)
Calculates the entropy of the given counter (in bits). |
static Counter |
getCountCounts(GenericCounter c)
|
static void |
incrementNonzero(Counter c1,
Counter 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 double |
informationRadius(GenericCounter c1,
GenericCounter c2)
Calculates the information radius (aka the Jensen-Shannon divergence) between the two Counters. |
static double |
jensenShannonDivergence(GenericCounter c1,
GenericCounter c2)
Calculates the Jensen-Shannon divergence between the two counters. |
static double |
klDivergence(GenericCounter from,
GenericCounter to)
Calculates the KL divergence between the two counters. |
static Counter |
linearCombination(GenericCounter c1,
double w1,
GenericCounter c2,
double w2)
Returns a Counter which is a weighted average of c1 and c2. |
static Counter |
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 Counter |
perturbCounts(GenericCounter c,
java.util.Random random,
double stdev,
boolean allowNegative)
|
static void |
printCounterComparison(GenericCounter a,
GenericCounter b)
Great for debugging. |
static void |
printCounterComparison(GenericCounter a,
GenericCounter b,
java.io.PrintStream out)
Great for debugging. |
static void |
printCounterSortedByKeys(GenericCounter c)
|
static Counter |
product(GenericCounter c1,
GenericCounter c2)
Returns the product of c1 and c2. |
static void |
saveCounter(GenericCounter c,
java.lang.String filename)
Saves a Counter to a text file. |
static Counter |
scale(GenericCounter c,
double s)
Scales each element in the Counter by the given scale factor. |
static double |
skewDivergence(GenericCounter c1,
GenericCounter c2,
double skew)
Calculates the skew divergence between the two counters. |
static PriorityQueue |
toPriorityQueue(GenericCounter c)
|
static java.util.List |
toSortedList(GenericCounter c)
|
static Counter |
union(GenericCounter c1,
GenericCounter 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 Counter union(GenericCounter c1, GenericCounter c2)
c1
- c2
-
public static Counter product(GenericCounter c1, GenericCounter c2)
c1
- c2
-
public static Counter division(GenericCounter c1, GenericCounter c2)
c1
- c2
-
public static double entropy(GenericCounter c)
public static double crossEntropy(GenericCounter from, GenericCounter to)
public static double crossEntropy(GenericCounter from, Distribution to, Counter justification)
public static double klDivergence(GenericCounter from, GenericCounter to)
from
- to
-
public static double jensenShannonDivergence(GenericCounter c1, GenericCounter c2)
c1
- c2
-
public static double skewDivergence(GenericCounter c1, GenericCounter c2, double skew)
c1
- c2
- skew
-
public static double informationRadius(GenericCounter c1, GenericCounter c2)
iRad(p,q) = D(p||(p+q)/2)+D(q,(p+q)/2)where p is one Counter, q is the other counter, and D(p||q) is the KL divergence bewteen p and q. Note that iRad(p,q) = iRad(q,p).
public static double cosine(GenericCounter c1, GenericCounter c2)
public static Counter average(GenericCounter c1, GenericCounter c2)
public static Counter linearCombination(GenericCounter c1, double w1, GenericCounter c2, double w2)
public static Counter perturbCounts(GenericCounter c, java.util.Random random, double stdev, boolean allowNegative)
public static Counter createCounterFromList(java.util.List l)
public static java.util.List toSortedList(GenericCounter c)
public static PriorityQueue toPriorityQueue(GenericCounter c)
public static void printCounterComparison(GenericCounter a, GenericCounter b)
a
- b
- public static void printCounterComparison(GenericCounter a, GenericCounter b, java.io.PrintStream out)
a
- b
- public static Counter getCountCounts(GenericCounter c)
public static Counter scale(GenericCounter c, double s)
public static void printCounterSortedByKeys(GenericCounter c)
public static Counter 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 void saveCounter(GenericCounter c, java.lang.String filename) throws java.io.IOException
c
- filename
-
java.io.IOException
public static void incrementNonzero(Counter c1, Counter c2)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |