edu.stanford.nlp.stats
Class TwoDimensionalCounter<K1,K2>

java.lang.Object
  extended by edu.stanford.nlp.stats.TwoDimensionalCounter<K1,K2>

public class TwoDimensionalCounter<K1,K2>
extends java.lang.Object

A class representing a mapping between pairs of typed objects and double values.


Constructor Summary
TwoDimensionalCounter()
           
TwoDimensionalCounter(MapFactory factory)
           
 
Method Summary
 void addAll(TwoDimensionalCounter<K1,K2> c)
           
 boolean containsKey(K1 o1, K2 o2)
           
 java.util.Set<K1> firstKeySet()
           
 Counter<Pair<K1,K2>> flatten()
           
 double getCount(K1 o1, K2 o2)
           
 Counter<K2> getCounter(K1 o)
           
 MapFactory getMapFactory()
           
 void incrementCount(K1 o1, K2 o2)
           
 void incrementCount(K1 o1, K2 o2, double count)
           
 boolean isEmpty()
           
static void main(java.lang.String[] args)
           
static TwoDimensionalCounter reverseIndexOrder(TwoDimensionalCounter cc)
          Produces a new ConditionalCounter.
 java.util.Set<K2> secondKeySet()
           
 void setCount(K1 o1, K2 o2, double count)
           
 Counter<K2> setCounter(K1 o, Counter<K2> c)
           
 int size()
           
 void subtractAll(TwoDimensionalCounter<K1,K2> c, boolean removeKeys)
           
 java.lang.String toCSVString(java.text.NumberFormat nf)
           
 java.lang.String toDatFileString()
           
 double[][] toMatrix(java.util.List<K1> firstKeys, java.util.List<K2> secondKeys)
          Given an ordering of the first (row) and second (column) keys, will produce a double matrix.
 java.lang.String toMatrixString(int cellSize)
           
 java.lang.String toString()
           
 double totalCount()
          Takes linear time.
 double totalCount(K1 k1)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TwoDimensionalCounter

public TwoDimensionalCounter()

TwoDimensionalCounter

public TwoDimensionalCounter(MapFactory factory)
Method Detail

getCounter

public Counter<K2> getCounter(K1 o)
Parameters:
o -
Returns:
the inner Counter associated with key o

size

public int size()
Returns:
total number of entries (key pairs)

containsKey

public boolean containsKey(K1 o1,
                           K2 o2)

incrementCount

public void incrementCount(K1 o1,
                           K2 o2)
Parameters:
o1 -
o2 -

incrementCount

public void incrementCount(K1 o1,
                           K2 o2,
                           double count)
Parameters:
o1 -
o2 -
count -

setCount

public void setCount(K1 o1,
                     K2 o2,
                     double count)
Parameters:
o1 -
o2 -
count -

getCount

public double getCount(K1 o1,
                       K2 o2)
Parameters:
o1 -
o2 -
Returns:

totalCount

public double totalCount()
Takes linear time.

Returns:

totalCount

public double totalCount(K1 k1)
Returns:

firstKeySet

public java.util.Set<K1> firstKeySet()

setCounter

public Counter<K2> setCounter(K1 o,
                              Counter<K2> c)

reverseIndexOrder

public static TwoDimensionalCounter reverseIndexOrder(TwoDimensionalCounter cc)
Produces a new ConditionalCounter.

Parameters:
cc -
Returns:
a new ConditionalCounter, where order of indices is reversed

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toDatFileString

public java.lang.String toDatFileString()

toMatrixString

public java.lang.String toMatrixString(int cellSize)

toMatrix

public double[][] toMatrix(java.util.List<K1> firstKeys,
                           java.util.List<K2> secondKeys)
Given an ordering of the first (row) and second (column) keys, will produce a double matrix.

Parameters:
firstKeys -
secondKeys -
Returns:

toCSVString

public java.lang.String toCSVString(java.text.NumberFormat nf)

secondKeySet

public java.util.Set<K2> secondKeySet()

isEmpty

public boolean isEmpty()

flatten

public Counter<Pair<K1,K2>> flatten()

addAll

public void addAll(TwoDimensionalCounter<K1,K2> c)

subtractAll

public void subtractAll(TwoDimensionalCounter<K1,K2> c,
                        boolean removeKeys)

getMapFactory

public MapFactory getMapFactory()

main

public static void main(java.lang.String[] args)