|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.GeneralizedCounter
A class for keeping double counts of List
s of a
prespecified length. A depth n GeneralizedCounter can be
thought of as a conditionalized count over n classes of
objects, in a prespecified order. Also offers a read-only view as
a Counter.
This class is serializable but no guarantees are made about compatibility version to version.
Field Summary | |
protected MutableDouble |
tempMDouble
|
Constructor Summary | |
GeneralizedCounter(int depth)
Constructs a new GeneralizedCounter of a specified depth |
Method Summary | |
GeneralizedCounter |
conditionalize(List l)
returns a GeneralizedCounter conditioned on the objects in the List argument. |
boolean |
containsKey(List key)
Like Counter , this currently returns true if the count is
explicitly 0.0 for something |
Counter |
counterView()
Returns a read-only synchronous view (not a snapshot) of this as a Counter . |
int |
depth()
Returns the depth of the GeneralizedCounter (i.e., the dimension of the distribution). |
Set |
entrySet()
returns the set of entries, where each key is a read-only List of size equal to the depth of the GeneralizedCounter, and
each value is a Double . |
double |
getCount(Object o)
Equivalent to ; works only
for depth 1 GeneralizedCounters |
double |
getCount(Object o1,
Object o2)
A convenience method equivalent to ; works only for depth 2
GeneralizedCounters |
double |
getCount(Object o1,
Object o2,
Object o3)
A convenience method equivalent to ; works only for depth 3
GeneralizedCounters |
double[] |
getCounts(List l)
returns a double[] array of length
depth+1 , containing the conditional counts on a
depth -length list given each level of conditional
distribution from 0 to depth . |
void |
incrementCount(Object o,
double count)
Equivalent to ;
only works for a depth 1 GeneralizedCounter. |
void |
incrementCounts(List l)
adds 1.0 |
void |
incrementCounts(List l,
double count)
adds count |
boolean |
isEmpty()
Returns true if nothing has a count. |
Set |
keySet()
returns the set of keys, as read-only List s of size
equal to the depth of the GeneralizedCounter. |
static void |
main(String[] args)
for testing purposes only |
Counter |
oneDimensionalCounterView()
Returns a read-only synchronous view (not a snapshot) of this as a Counter . |
Set |
topLevelKeySet()
|
String |
toString()
|
double |
totalCount()
returns the total count of objects in the GeneralizedCounter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected transient MutableDouble tempMDouble
Constructor Detail |
public GeneralizedCounter(int depth)
depth
- the depth of the GeneralizedCounterMethod Detail |
public Set entrySet()
List
of size equal to the depth of the GeneralizedCounter, and
each value is a Double
.
public double totalCount()
public Set topLevelKeySet()
public Set keySet()
List
s of size
equal to the depth of the GeneralizedCounter.
public int depth()
public boolean isEmpty()
public double getCount(Object o)
getCounts(java.util.List)
({o})
; works only
for depth 1 GeneralizedCounters
public double getCount(Object o1, Object o2)
getCounts(java.util.List)
({o1,o2})
; works only for depth 2
GeneralizedCounters
public double getCount(Object o1, Object o2, Object o3)
getCounts(java.util.List)
({o1,o2,o3})
; works only for depth 3
GeneralizedCounters
public double[] getCounts(List l)
double[]
array of length
depth+1
, containing the conditional counts on a
depth
-length list given each level of conditional
distribution from 0 to depth
.
public GeneralizedCounter conditionalize(List l)
List
argument. The length of the argument List
must be less than the depth of the GeneralizedCounter.
public void incrementCounts(List l)
public void incrementCounts(List l, double count)
public void incrementCount(Object o, double count)
incrementCounts(java.util.List)
({o}, count)
;
only works for a depth 1 GeneralizedCounter.
public boolean containsKey(List key)
Counter
, this currently returns true if the count is
explicitly 0.0 for something
public Counter counterView()
this
as a Counter
. Any calls to
count-changing or entry-removing operations will result in an
UnsupportedOperationException
. At some point in the
future, this view may gain limited writable functionality.
public Counter oneDimensionalCounterView()
this
as a Counter
. Works only with one-dimensional
GeneralizedCounters. Exactly like counterView()
, except
that getCount(java.lang.Object)
operates on primitive objects of the counter instead
of singleton lists. Any calls to
count-changing or entry-removing operations will result in an
UnsupportedOperationException
. At some point in the
future, this view may gain limited writable functionality.
public String toString()
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |